Skip to content

Commit

Permalink
Merge 81c31f9 into 0a6f986
Browse files Browse the repository at this point in the history
  • Loading branch information
predicat committed Dec 11, 2017
2 parents 0a6f986 + 81c31f9 commit 6967e8b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/coinmarketcap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def self.coins(limit = nil)
end
end

def self.coin(id)
HTTParty.get("https://api.coinmarketcap.com/v1/ticker/#{id}/")
def self.coin(id, currency = 'USD')
HTTParty.get("https://api.coinmarketcap.com/v1/ticker/#{id}/?convert=#{currency}")
end

def self.global(currency = 'USD')
Expand Down
12 changes: 12 additions & 0 deletions spec/coinmarketcap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@
end
end
end

context 'with valid id and a currency code' do
it "should receive a 200 response with coin details" do
VCR.use_cassette('single_eur_coin_response') do
response = Coinmarketcap.coin('bitcoin', 'EUR')
coin = JSON.parse(response.body)
expect(response.code).to eq(200)
expect(coin.count).to eq(1)
expect(coin.first['market_cap_eur'].to_i).to be > 0
end
end
end
end

describe "#global" do
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/cassettes/single_coin_response.yml

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

65 changes: 65 additions & 0 deletions spec/fixtures/cassettes/single_eur_coin_response.yml

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

2 changes: 1 addition & 1 deletion spec/fixtures/cassettes/wrong_coin_response.yml

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

0 comments on commit 6967e8b

Please sign in to comment.