Skip to content

Commit

Permalink
Add client specs and VCR cassettes
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Bates committed Feb 8, 2018
1 parent a5707af commit 69cb1b3
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
coderay (1.1.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
hashdiff (0.3.0)
httparty (0.15.7)
multi_xml (>= 0.5.2)
method_source (0.8.2)
Expand All @@ -23,6 +28,7 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (3.0.1)
rainbow (3.0.0)
rake (10.5.0)
rspec (3.7.0)
Expand All @@ -46,9 +52,15 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
slop (3.6.0)
thor (0.20.0)
unicode-display_width (1.3.0)
vcr (3.0.3)
webmock (2.1.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff

PLATFORMS
ruby
Expand All @@ -60,6 +72,8 @@ DEPENDENCIES
rake (~> 10.0)
rspec (~> 3.0)
rubocop (~> 0.52.1)
vcr
webmock

BUNDLED WITH
1.16.1
2 changes: 2 additions & 0 deletions hodlmoon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 10.0'
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'
end
21 changes: 21 additions & 0 deletions spec/client/coin_market_cap_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RSpec.describe Hodlmoon::Client::CoinMarketCap do
describe '#retrieve_price', :vcr do
subject(:client) { described_class.retrieve_price('ethereum', currency) }

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

it 'returns the current coin price in pounds' do
expect(client).to eq('580.697337402')
end
end

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

it 'returns the current coin price in dollars' do
expect(client).to eq('808.738')
end
end
end
end
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
require 'bundler/setup'
require 'hodlmoon'
require 'webmock/rspec'
require 'vcr'

WebMock.disable_net_connect!(allow_localhost: true)

VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr'
c.hook_into :webmock
c.configure_rspec_metadata!
end

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down

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

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

0 comments on commit 69cb1b3

Please sign in to comment.