vend 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +57 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +1 -1
  5. data/example.rb +3 -3
  6. data/lib/vend.rb +2 -1
  7. data/lib/vend/base.rb +12 -12
  8. data/lib/vend/base_factory.rb +2 -6
  9. data/lib/vend/client.rb +5 -5
  10. data/lib/vend/http_client.rb +30 -31
  11. data/lib/vend/null_logger.rb +9 -5
  12. data/lib/vend/oauth2/auth_code.rb +7 -10
  13. data/lib/vend/oauth2/client.rb +1 -5
  14. data/lib/vend/pagination_info.rb +2 -1
  15. data/lib/vend/resource/customer.rb +1 -3
  16. data/lib/vend/resource/outlet.rb +0 -2
  17. data/lib/vend/resource/payment_type.rb +0 -2
  18. data/lib/vend/resource/product.rb +0 -2
  19. data/lib/vend/resource/register.rb +0 -2
  20. data/lib/vend/resource/register_sale.rb +2 -5
  21. data/lib/vend/resource/register_sale_product.rb +1 -1
  22. data/lib/vend/resource/supplier.rb +23 -0
  23. data/lib/vend/resource/tax.rb +0 -2
  24. data/lib/vend/resource/user.rb +0 -2
  25. data/lib/vend/resource_collection.rb +11 -15
  26. data/lib/vend/scope.rb +1 -2
  27. data/lib/vend/version.rb +1 -1
  28. data/spec/integration/customer_spec.rb +12 -9
  29. data/spec/integration/outlet_spec.rb +2 -3
  30. data/spec/integration/payment_types_spec.rb +1 -2
  31. data/spec/integration/product_spec.rb +26 -29
  32. data/spec/integration/register_sale_spec.rb +9 -10
  33. data/spec/integration/register_spec.rb +1 -2
  34. data/spec/integration/supplier_spec.rb +14 -0
  35. data/spec/integration/tax_spec.rb +1 -2
  36. data/spec/integration/user_spec.rb +1 -2
  37. data/spec/mock_responses/suppliers.json +36 -0
  38. data/spec/spec_helper.rb +1 -2
  39. data/spec/support/matchers/have_attributes.rb +3 -3
  40. data/spec/support/shared_examples/integration.rb +7 -9
  41. data/spec/support/shared_examples/logger.rb +21 -10
  42. data/spec/vend/base_factory_spec.rb +11 -12
  43. data/spec/vend/base_spec.rb +22 -23
  44. data/spec/vend/client_spec.rb +40 -39
  45. data/spec/vend/http_client_spec.rb +70 -62
  46. data/spec/vend/null_logger_spec.rb +1 -1
  47. data/spec/vend/oauth2/auth_code_spec.rb +18 -17
  48. data/spec/vend/oauth2/client_spec.rb +21 -21
  49. data/spec/vend/pagination_info_spec.rb +40 -17
  50. data/spec/vend/resource/register_sale_product_spec.rb +8 -6
  51. data/spec/vend/resource/register_sale_spec.rb +7 -8
  52. data/spec/vend/resource_collection_spec.rb +108 -95
  53. data/spec/vend/scope_spec.rb +20 -12
  54. data/vend.gemspec +5 -6
  55. metadata +10 -20
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vend::Resource::RegisterSale do
4
-
5
4
  let(:expected_attributes) do
6
5
  {
7
6
  'id' => '98ce3dbf-e862-c811-fa93-10f6db3a8f66',
@@ -18,20 +17,20 @@ describe Vend::Resource::RegisterSale do
18
17
 
19
18
  let(:expected_collection_length) { 1 }
20
19
 
21
- it_should_behave_like "a resource with a singular GET endpoint"
22
- it_should_behave_like "a resource with a collection GET endpoint" do
20
+ it_behaves_like "a resource with a singular GET endpoint"
21
+ it_behaves_like "a resource with a collection GET endpoint" do
23
22
  let(:append_to_url) { '?page_size=200' }
24
23
  end
25
24
 
26
- specify "register_sales are findable by state" do
27
- client.RegisterSale.should respond_to(:find_by_state)
25
+ it "register_sales are findable by state" do
26
+ expect(client.RegisterSale).to respond_to(:find_by_state)
28
27
 
29
- stub_request(:get, "https://bar:baz@foo.vendhq.com/api/register_sales?status[]=OPEN&status[]=CLOSED").
30
- to_return(:status => 200, :body => get_mock_response('register_sales.find_by_state.json'))
28
+ stub_request(:get, "https://bar:baz@foo.vendhq.com/api/register_sales?status[]=OPEN&status[]=CLOSED")
29
+ .to_return(status: 200, body: get_mock_response('register_sales.find_by_state.json'))
31
30
 
32
31
  collection = client.RegisterSale.find_by_state([:OPEN, :CLOSED])
33
- collection.first.should be_a Vend::Resource::RegisterSale
34
- collection.first.id.should == "8dd57077-c158-f7db-d582-6785f43c9d72"
35
- collection.first.register_sale_products.count.should == 2
32
+ expect(collection.first).to be_a Vend::Resource::RegisterSale
33
+ expect(collection.first.id).to eq "8dd57077-c158-f7db-d582-6785f43c9d72"
34
+ expect(collection.first.register_sale_products.count).to eq 2
36
35
  end
37
36
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vend::Resource::Register do
4
-
5
4
  let(:expected_attributes) do
6
5
  {
7
6
  'id' => '6cbe2342-3d5f-11e0-8697-4040f540b50a',
@@ -12,5 +11,5 @@ describe Vend::Resource::Register do
12
11
 
13
12
  let(:expected_collection_length) { 1 }
14
13
 
15
- it_should_behave_like "a resource with a collection GET endpoint"
14
+ it_behaves_like "a resource with a collection GET endpoint"
16
15
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vend::Resource::Supplier do
4
+ let(:expected_attributes) do
5
+ {
6
+ 'id' => '9fc84329-2d20-11e2-8057-080027706aa2',
7
+ 'name' => 'Brewer Supplies Ltd.'
8
+ }
9
+ end
10
+
11
+ let(:expected_collection_length) { 1 }
12
+
13
+ it_behaves_like "a resource with a collection GET endpoint"
14
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vend::Resource::Tax do
4
-
5
4
  let(:expected_attributes) do
6
5
  {
7
6
  'id' => '53b3501c-887c-102d-8a4b-a9cf13f17faa',
@@ -12,5 +11,5 @@ describe Vend::Resource::Tax do
12
11
 
13
12
  let(:expected_collection_length) { 1 }
14
13
 
15
- it_should_behave_like "a resource with a collection GET endpoint"
14
+ it_behaves_like "a resource with a collection GET endpoint"
16
15
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vend::Resource::User do
4
-
5
4
  let(:expected_attributes) do
6
5
  {
7
6
  'id' => '6ce4286c-3d5f-11e0-8697-4040f540b50a',
@@ -12,5 +11,5 @@ describe Vend::Resource::User do
12
11
 
13
12
  let(:expected_collection_length) { 2 }
14
13
 
15
- it_should_behave_like "a resource with a collection GET endpoint"
14
+ it_behaves_like "a resource with a collection GET endpoint"
16
15
  end
@@ -0,0 +1,36 @@
1
+ {
2
+ "suppliers": [
3
+ {
4
+ "id": "9fc84329-2d20-11e2-8057-080027706aa2",
5
+ "retailer_id": "9a5521c3-2d20-11e2-8057-080027706aa2",
6
+ "name": "Brewer Supplies Ltd.",
7
+ "description": "We supply all things brewed\n",
8
+ "source": "USER",
9
+ "contact": {
10
+ "first_name": "First",
11
+ "last_name": "Last",
12
+ "company_name": "Co co",
13
+ "phone": "1-234-555-1234",
14
+ "mobile": null,
15
+ "fax": null,
16
+ "email": "no-reply+brewer-contact@vendhq.com",
17
+ "twitter": null,
18
+ "website": "www.brewer-supplies.com",
19
+ "physical_address1": null,
20
+ "physical_address2": null,
21
+ "physical_suburb": null,
22
+ "physical_city": null,
23
+ "physical_postcode": null,
24
+ "physical_state": null,
25
+ "physical_country_id": null,
26
+ "postal_address1": "123 Street St",
27
+ "postal_address2": null,
28
+ "postal_suburb": "Suburbia",
29
+ "postal_city": "New York",
30
+ "postal_postcode": "12345",
31
+ "postal_state": "New York",
32
+ "postal_country_id": "US"
33
+ }
34
+ }
35
+ ]
36
+ }
@@ -2,9 +2,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  require 'rubygems'
3
3
  require 'bundler/setup'
4
4
  require 'webmock/rspec'
5
- require 'rspec/its'
6
5
  require 'pry'
7
- Dir["./spec/support/**/*.rb"].each {|f| require f}
6
+ Dir["./spec/support/**/*.rb"].each { |f| require f }
8
7
 
9
8
  require 'cgi'
10
9
  require 'vend'
@@ -1,7 +1,7 @@
1
1
  RSpec::Matchers.define :have_attributes do |expected|
2
- match do |attributes|
3
- expected.each do |key,value|
4
- actual.send(key).should == value
2
+ match do |_attributes|
3
+ expected.each do |key, value|
4
+ expect(actual.send(key)).to eq value
5
5
  end
6
6
  end
7
7
 
@@ -29,12 +29,11 @@ shared_examples "a resource with a collection GET endpoint" do
29
29
 
30
30
  it "gets the collection" do
31
31
  url = "https://%s:%s@%s.vendhq.com/api/%s%s" % [
32
- username, password, store, class_basename.to_s.underscore.pluralize,
33
- append_to_url
32
+ username, password, store, described_class.collection_name, append_to_url
34
33
  ]
35
34
 
36
35
  stub_request(:get, url).to_return(
37
- :status => 200, :body => get_mock_from_path(:get)
36
+ status: 200, body: get_mock_from_path(:get)
38
37
  )
39
38
 
40
39
  collection = build_receiver.all
@@ -55,11 +54,11 @@ shared_examples "a resource with a singular GET endpoint" do
55
54
  end
56
55
 
57
56
  it "gets the resource" do
58
- stub_request(:get, "https://#{username}:#{password}@#{store}.vendhq.com/api/#{class_basename.to_s.underscore.pluralize}/#{id}").
59
- to_return(:status => 200, :body => get_mock_from_path(:get, :id => id))
57
+ stub_request(:get, "https://#{username}:#{password}@#{store}.vendhq.com/api/#{class_basename.to_s.underscore.pluralize}/#{id}")
58
+ .to_return(status: 200, body: get_mock_from_path(:get, id: id))
60
59
 
61
60
  objekt = build_receiver.find(id)
62
- objekt.should have_attributes(expected_attributes)
61
+ expect(objekt).to have_attributes(expected_attributes)
63
62
  end
64
63
  end
65
64
 
@@ -73,9 +72,8 @@ shared_examples "a resource with a DELETE endpoint" do
73
72
  end
74
73
 
75
74
  it "deletes the resource" do
76
-
77
- stub_request(:delete, "https://#{username}:#{password}@#{store}.vendhq.com/api/#{class_basename.to_s.underscore.pluralize}/#{expected_attributes['id']}").
78
- to_return(status: 200, body: {}.to_json)
75
+ stub_request(:delete, "https://#{username}:#{password}@#{store}.vendhq.com/api/#{class_basename.to_s.underscore.pluralize}/#{expected_attributes['id']}")
76
+ .to_return(status: 200, body: {}.to_json)
79
77
 
80
78
  objekt = build_receiver.build(expected_attributes)
81
79
  expect(objekt.delete).to be_truthy
@@ -1,25 +1,36 @@
1
1
  shared_examples_for "a logger" do
2
- it { should respond_to(:debug) }
3
- it { should respond_to(:info) }
4
- it { should respond_to(:warn) }
5
- it { should respond_to(:error) }
6
- it { should respond_to(:fatal) }
2
+ specify :responds_to_debug do
3
+ expect(subject).to respond_to(:debug)
4
+ end
5
+
6
+ specify :responds_to_info do
7
+ expect(subject).to respond_to(:info)
8
+ end
9
+
10
+ specify :responds_to_warn do
11
+ expect(subject).to respond_to(:warn)
12
+ end
13
+
14
+ specify :responds_to_error do
15
+ expect(subject).to respond_to(:error)
16
+ end
17
+
18
+ specify :responds_to_fatal do
19
+ expect(subject).to respond_to(:fatal)
20
+ end
7
21
  end
8
22
 
9
23
  shared_examples_for "it has a logger" do
10
24
  describe "#logger" do
11
-
12
25
  let(:logger) { double("logger") }
13
26
 
14
27
  it "defaults to a null logger" do
15
- subject.logger.should be_instance_of(Vend::NullLogger)
28
+ expect(subject.logger).to be_instance_of(Vend::NullLogger)
16
29
  end
17
30
 
18
31
  it "allows the logger to be set" do
19
32
  subject.logger = logger
20
- subject.logger.should == logger
33
+ expect(subject.logger).to eq logger
21
34
  end
22
-
23
35
  end
24
-
25
36
  end
@@ -7,42 +7,41 @@ describe Vend::BaseFactory do
7
7
  class Vend::Resource::Foo < Vend::Base #:nodoc:
8
8
  end
9
9
 
10
- let(:client) { double() }
10
+ let(:client) { double }
11
11
  subject { Vend::Resource::FooFactory.new(client, Vend::Resource::Foo) }
12
12
 
13
13
  it "initializes correctly" do
14
- subject.should be_instance_of(Vend::Resource::FooFactory)
15
- subject.client.should == client
16
- subject.target_class.should == Vend::Resource::Foo
14
+ expect(subject).to be_instance_of(Vend::Resource::FooFactory)
15
+ expect(subject.client).to eq client
16
+ expect(subject.target_class).to eq Vend::Resource::Foo
17
17
  end
18
18
 
19
19
  it "proxies 'find' to the target class" do
20
- Vend::Resource::Foo.should_receive(:find)
20
+ expect(Vend::Resource::Foo).to receive(:find)
21
21
  subject.find
22
22
  end
23
23
 
24
24
  it "proxies 'all' to the target class" do
25
- Vend::Resource::Foo.should_receive(:all)
25
+ expect(Vend::Resource::Foo).to receive(:all)
26
26
  subject.all
27
27
  end
28
28
 
29
29
  it "proxies 'since' to the target class" do
30
- Vend::Resource::Foo.should_receive(:since)
30
+ expect(Vend::Resource::Foo).to receive(:since)
31
31
  subject.since
32
32
  end
33
-
33
+
34
34
  it "proxies 'outlet_id' to the target class" do
35
- Vend::Resource::Foo.should_receive(:outlet_id)
35
+ expect(Vend::Resource::Foo).to receive(:outlet_id)
36
36
  subject.outlet_id
37
37
  end
38
38
 
39
39
  it "proxies 'build' to the target class" do
40
- Vend::Resource::Foo.should_receive(:build)
40
+ expect(Vend::Resource::Foo).to receive(:build)
41
41
  subject.build
42
42
  end
43
43
 
44
44
  it "returns the target class" do
45
- subject.target_class.should == Vend::Resource::Foo
45
+ expect(subject.target_class).to eq Vend::Resource::Foo
46
46
  end
47
-
48
47
  end
@@ -7,16 +7,16 @@ describe Vend::Base do
7
7
 
8
8
  let(:client) { double(:client) }
9
9
  let(:attribute_hash) { { key: 'value', 'id' => 1} }
10
- let(:mock_response) {
10
+ let(:mock_response) do
11
11
  {
12
- 'foos'=>[
13
- {'id'=>'1','bar'=>'baz'},
14
- {'id'=>'2','flar'=>'flum'}
12
+ 'foos' => [
13
+ {'id' => '1', 'bar' => 'baz'},
14
+ {'id' => '2', 'flar' => 'flum'}
15
15
  ]
16
16
  }
17
- }
17
+ end
18
18
 
19
- subject { Vend::Resource::Foo.new(client, :attrs => attribute_hash) }
19
+ subject { Vend::Resource::Foo.new(client, attrs: attribute_hash) }
20
20
 
21
21
  it 'creates an instance of Foo' do
22
22
  expect(subject).to be_instance_of(Vend::Resource::Foo)
@@ -42,7 +42,6 @@ describe Vend::Base do
42
42
  expect(resource).to be_a Vend::Resource::Foo
43
43
  expect(resource.bar).to eq 'baz'
44
44
  end
45
-
46
45
  end
47
46
 
48
47
  describe '.initialize_collection' do
@@ -85,7 +84,7 @@ describe Vend::Base do
85
84
  end
86
85
 
87
86
  describe '#singular_name' do
88
- it :singular_name do
87
+ specify :singular_name do
89
88
  expect(subject.singular_name).to eq "foos/#{subject.id}"
90
89
  end
91
90
  end
@@ -114,7 +113,7 @@ describe Vend::Base do
114
113
  let(:resource_collection) { double('resource_collection') }
115
114
 
116
115
  before do
117
- subject.stub(:collection_name => collection_name)
116
+ subject.stub(collection_name: collection_name)
118
117
  end
119
118
 
120
119
  it 'calls initialize_collection with the collection_name' do
@@ -133,7 +132,7 @@ describe Vend::Base do
133
132
  let(:bar) { double('bar') }
134
133
 
135
134
  before do
136
- subject.stub(:collection_name => collection_name)
135
+ subject.stub(collection_name: collection_name)
137
136
  end
138
137
 
139
138
  it 'calls initialize_collection with collection_name and :bar arg' do
@@ -156,12 +155,12 @@ describe Vend::Base do
156
155
  let(:query) { 'query' }
157
156
 
158
157
  before do
159
- subject.stub(:collection_name => collection_name)
158
+ subject.stub(collection_name: collection_name)
160
159
  end
161
160
 
162
161
  it 'calls initialize_collection with collection_name and :outlet_id arg' do
163
162
  expect(subject).to receive(:initialize_collection).with(
164
- client, collection_name, :url_params => { field.to_sym => query }
163
+ client, collection_name, url_params: { field.to_sym => query }
165
164
  ) { resource_collection }
166
165
  expect(subject.search(client, field, query)).to eq resource_collection
167
166
  end
@@ -188,7 +187,7 @@ describe Vend::Base do
188
187
 
189
188
  describe 'dynamic instance methods' do
190
189
  let(:attrs) { { 'one' => 'foo', 'two' => 'bar', 'object_id' => 'fail' } }
191
- subject { Vend::Resource::Foo.new(client, :attrs => attrs) }
190
+ subject { Vend::Resource::Foo.new(client, attrs: attrs) }
192
191
 
193
192
  it 'responds to top level attributes' do
194
193
  expect(subject).to respond_to(:one)
@@ -203,12 +202,12 @@ describe Vend::Base do
203
202
 
204
203
  describe 'delete!' do
205
204
  context 'when id is present' do
206
- subject { Vend::Resource::Foo.new(client, :attrs => {'id' => 1}) }
205
+ subject { Vend::Resource::Foo.new(client, attrs: {'id' => 1}) }
207
206
 
208
- let(:singular_name) { double('singular_name')}
207
+ let(:singular_name) { double('singular_name') }
209
208
 
210
209
  before do
211
- subject.stub(:singular_name => singular_name)
210
+ subject.stub(singular_name: singular_name)
212
211
  end
213
212
 
214
213
  it 'deletes the object' do
@@ -218,20 +217,20 @@ describe Vend::Base do
218
217
  end
219
218
 
220
219
  context 'when id is absent' do
221
- subject { Vend::Resource::Foo.new(client, :attrs => {:foo => 'bar'}) }
220
+ subject { Vend::Resource::Foo.new(client, attrs: {foo: 'bar'}) }
222
221
 
223
222
  it 'raises Vend::Resource::IllegalAction' do
224
223
  expect(client).to_not receive(:request)
225
- expect {
224
+ expect do
226
225
  subject.delete!
227
- }.to raise_error(Vend::Resource::IllegalAction, 'Vend::Resource::Foo has no unique ID')
226
+ end.to raise_error(Vend::Resource::IllegalAction, 'Vend::Resource::Foo has no unique ID')
228
227
  end
229
228
  end
230
229
  end
231
230
 
232
231
  describe 'delete' do
233
232
  it 'returns false when no id is present' do
234
- subject = Vend::Resource::Foo.new(client, :attrs => {:foo => 'bar'})
233
+ subject = Vend::Resource::Foo.new(client, attrs: {foo: 'bar'})
235
234
  expect(client).to_not receive(:request)
236
235
  expect(subject.delete).to be_falsey
237
236
  end
@@ -239,7 +238,7 @@ describe Vend::Base do
239
238
 
240
239
  describe '.default_collection_request_args' do
241
240
  subject { Vend::Resource::Foo }
242
- it :default_collection_request_args do
241
+ specify :default_collection_request_args do
243
242
  expect(subject.default_collection_request_args).to eq({})
244
243
  end
245
244
  end
@@ -254,13 +253,13 @@ describe Vend::Base do
254
253
 
255
254
  describe '.available_scopes' do
256
255
  subject { Vend::Resource::Foo }
257
- it :available_scopes do
256
+ specify :available_scopes do
258
257
  expect(subject.available_scopes).to eq [:bar]
259
258
  end
260
259
  end
261
260
 
262
261
  describe '.accepts_scope?' do
263
- let(:scope_name) {:scope_name}
262
+ let(:scope_name) { :scope_name }
264
263
  subject { Vend::Resource::Foo }
265
264
 
266
265
  context 'when scope is accepted' do
@@ -1,93 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Vend::Client do
4
+ subject { Vend::Client.new('store', 'user', 'password') }
5
+ it_behaves_like "it has a logger"
4
6
 
5
- subject { Vend::Client.new('store','user','password') }
7
+ specify :store do
8
+ expect(subject.store).to eq 'store'
9
+ end
6
10
 
7
- it_should_behave_like "it has a logger"
11
+ specify :username do
12
+ expect(subject.username).to eq 'user'
13
+ end
8
14
 
9
- its(:store) { should == 'store' }
10
- its(:username) { should == 'user' }
11
- its(:password) { should == 'password' }
15
+ specify :password do
16
+ expect(subject.password).to eq 'password'
17
+ end
12
18
 
13
19
  it "creates an instance of Client" do
14
- subject.should be_instance_of(Vend::Client)
20
+ expect(subject).to be_instance_of(Vend::Client)
15
21
  end
16
22
 
17
23
  it "returns the API base url" do
18
- subject.base_url.should == "https://store.vendhq.com/api/"
24
+ expect(subject.base_url).to eq "https://store.vendhq.com/api/"
19
25
  end
20
26
 
21
- it "should set options" do
22
- options = { :key => :value }
23
- client = Vend::Client.new('store','user','password', options)
27
+ it "sets options" do
28
+ options = { key: :value }
29
+ client = Vend::Client.new('store', 'user', 'password', options)
24
30
  options.each do |key, value|
25
- client.options[key].should == value
31
+ expect(client.options[key]).to eq value
26
32
  end
27
33
  end
28
34
 
29
35
  describe "resource factories" do
30
36
  it "gets all products" do
31
- Vend::Resource::Product.should_receive(:all).and_return([])
32
- subject.Product.all.should == []
37
+ expect(Vend::Resource::Product).to receive(:all).and_return([])
38
+ expect(subject.Product.all).to eq []
33
39
  end
34
40
  end
35
41
 
36
42
  describe "#http_client" do
37
-
38
43
  let(:http_client) { double("http_client") }
39
44
  let(:http_client_options) { double("http_client_options") }
40
45
 
41
46
  before do
42
- subject.stub(:http_client_options => http_client_options)
43
- Vend::HttpClient.should_receive(:new).with(http_client_options) { http_client }
47
+ subject.stub(http_client_options: http_client_options)
48
+ expect(Vend::HttpClient).to receive(:new).with(http_client_options) { http_client }
44
49
  end
45
50
 
46
- it "should return a memoized HttpClient instance" do
47
- subject.http_client.should == http_client
48
- subject.http_client.should == http_client
51
+ it "returns a memoized HttpClient instance" do
52
+ expect(subject.http_client).to eq http_client
53
+ expect(subject.http_client).to eq http_client
49
54
  end
50
-
51
55
  end
52
56
 
53
57
  describe "#http_client_options" do
54
-
55
- let(:options) { {:foo => 'bar'} }
58
+ let(:options) { {foo: 'bar'} }
56
59
  let(:base_url) { "http://foo/" }
57
60
  let(:username) { "username" }
58
61
  let(:password) { "password" }
59
62
 
60
63
  before do
61
64
  subject.stub(
62
- :options => options,
63
- :base_url => base_url,
64
- :username => username,
65
- :password => password
65
+ options: options,
66
+ base_url: base_url,
67
+ username: username,
68
+ password: password
66
69
  )
67
70
  end
68
-
69
- its(:http_client_options) {
70
- should == {
71
- :foo => 'bar',
72
- :base_url => base_url,
73
- :username => username,
74
- :password => password
75
- }
76
- }
71
+ specify :http_client_options do
72
+ expect(subject.http_client_options).to eq({
73
+ foo: 'bar',
74
+ base_url: base_url,
75
+ username: username,
76
+ password: password
77
+ })
78
+ end
77
79
  end
78
80
 
79
81
  describe "#request" do
80
-
81
82
  let(:response) { double("response") }
82
83
  let(:http_client) { double("http_client") }
83
84
 
84
85
  before do
85
- subject.stub(:http_client => http_client)
86
- http_client.should_receive(:request).with("foo", "bar") { response }
86
+ subject.stub(http_client: http_client)
87
+ expect(http_client).to receive(:request).with("foo", "bar") { response }
87
88
  end
88
89
 
89
90
  it "delegates to the http_client" do
90
- subject.request("foo", "bar").should == response
91
+ expect(subject.request("foo", "bar")).to eq response
91
92
  end
92
93
  end
93
94
  end