Skip to content

Commit

Permalink
Add RetrieveList specs and update webmock
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Bates committed Feb 11, 2018
1 parent ef26780 commit 5e8b243
Show file tree
Hide file tree
Showing 12 changed files with 619 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GEM
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
formatador (0.2.5)
hashdiff (0.3.0)
hashdiff (0.3.7)
httparty (0.15.7)
multi_xml (>= 0.5.2)
method_source (0.8.2)
Expand Down Expand Up @@ -62,7 +62,7 @@ GEM
thor (0.20.0)
unicode-display_width (1.3.0)
vcr (3.0.3)
webmock (2.1.0)
webmock (3.2.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand All @@ -78,7 +78,7 @@ DEPENDENCIES
rspec (~> 3.0)
rubocop (~> 0.52.1)
vcr
webmock
webmock (~> 3.2.1)

BUNDLED WITH
1.16.1
2 changes: 1 addition & 1 deletion hodlmoon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.52.1'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'webmock'
spec.add_development_dependency 'webmock', '~> 3.2.1'
end
2 changes: 1 addition & 1 deletion lib/hodlmoon/client/retrieve_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call
private

def uri
"https://api.coinmarketcap.com/v1/ticker?limit=#{@limit}&convert=#{@currency}"
"https://api.coinmarketcap.com/v1/ticker/?limit=#{@limit}&convert=#{@currency}"
end
end
end
Expand Down
31 changes: 31 additions & 0 deletions spec/client/retrieve_list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'pry'

RSpec.describe Hodlmoon::Client::RetrieveList do
describe '#call', :vcr do
subject(:client) { described_class.call(12, currency) }

context 'with gbp' do
let(:currency) { 'gbp' }

it 'returns the correct limit' do
expect(client.count).to eq(12)
end

it 'returns the gbp headers' do
expect(client.first.keys).to include('price_gbp', '24h_volume_gbp', 'market_cap_gbp')
end
end

context 'with usd' do
let(:currency) { 'usd' }

it 'returns the correct limit' do
expect(client.count).to eq(12)
end

it 'returns the usd headers' do
expect(client.first.keys).to include('price_usd', '24h_volume_usd', 'market_cap_usd')
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.describe Hodlmoon::Client::CoinMarketCap do
describe '#retrieve_price', :vcr do
subject(:client) { described_class.retrieve_price('ethereum', currency) }
RSpec.describe Hodlmoon::Client::RetrievePrice do
describe '#call', :vcr do
subject(:client) { described_class.call('ethereum', currency) }

context 'with gbp' do
let(:currency) { 'gbp' }
Expand Down
4 changes: 0 additions & 4 deletions spec/hodlmoon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
it 'has a version number' do
expect(Hodlmoon::VERSION).not_to be nil
end

it 'does something useful' do
expect(false).to eq(true)
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e8b243

Please sign in to comment.