mad_cart 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 450e045c29572b5f75ffe9e6e21a9a608d6773f9
4
- data.tar.gz: ff7b972a1438efa3421e8399b7bcdcfcadfde030
3
+ metadata.gz: 4b414baa5cd556c5664acb0daf217ee9e41d9489
4
+ data.tar.gz: 1e64b3d30bb94d163532c25cfcc11d8773effc7f
5
5
  SHA512:
6
- metadata.gz: a0ec1b9b0b0882efadbd8b9c405875f16dbd98b9a28f28869f2f0d374e72dd49d7644f9135e33438919c905b2d7a52d3ed54775443850244c9c279d434b3b748
7
- data.tar.gz: d5f0ddc64d5a44ad69df71720d2f769ada23ee57eae6b0b6b801c85bd561c7e622ec024220cec417ffefb7dd2abb60d995f9a1f559d461b7b0d06d2369879665
6
+ metadata.gz: 2341f979b1f6f50db08f1077574a521c40e877087431d130eb552c6b0098ed35f08598b2c81b1bcbd2a05b23d6ddf7eb3dfa473bb1d2518d8f53095c6645cb16
7
+ data.tar.gz: c8491b179797a5e7fc17aa4e3427353a0a38235e7f79f3bdf6c9aad615a2157d907ade75330528db96f1fc522f51cb8dd346cfb47fc93343c2b75ab1e63781f4
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.5
4
+ cache:
5
+ - bundler
6
+ script:
7
+ - bundle exec rspec spec
@@ -65,6 +65,8 @@ module MadCart
65
65
  case response.status
66
66
  when 401
67
67
  raise InvalidCredentials
68
+ when 404
69
+ raise InvalidStore
68
70
  when 500
69
71
  raise ServerError
70
72
  end
@@ -1,3 +1,3 @@
1
1
  module MadCart
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -8,9 +8,8 @@ describe "configuration" do
8
8
  end
9
9
 
10
10
  describe "stores" do
11
-
12
11
  it "does not require store to be added if credentials are passed to constructor" do
13
- lambda{ MadCart::Store::BigCommerce.new({:api_key => 'a_fake_key', :store_url => '/path/to/store', :username => 'bob'}) }.should_not raise_error
12
+ expect { MadCart::Store::BigCommerce.new({:api_key => 'a_fake_key', :store_url => '/path/to/store', :username => 'bob'}) }.not_to raise_error
14
13
  end
15
14
 
16
15
  it "allows config values to be set for a store" do
@@ -19,24 +18,23 @@ describe "configuration" do
19
18
  config.add_store :big_commerce, config_data
20
19
  end
21
20
 
22
- MadCart.config.big_commerce.should == config_data
21
+ expect(MadCart.config.big_commerce).to eql(config_data)
23
22
  end
24
23
 
25
24
  it "gives returns nil if there's no config" do
26
- MadCart.config.missing_store.should be_nil
25
+ expect(MadCart.config.missing_store).to be_nil
27
26
  end
28
-
29
27
  end
30
28
 
31
29
  describe "models" do
32
30
  it "allows custom attribute names to be set" do
33
- lambda {
31
+ expect {
34
32
  MadCart.configure do |config|
35
33
  config.attribute_map :products, {"name" => "title"}
36
34
  end
37
- }.should_not raise_error
35
+ }.not_to raise_error
38
36
 
39
- MadCart.config.attribute_maps["products"].should == {"name" => "title"}
37
+ expect(MadCart.config.attribute_maps["products"]).to eql({"name" => "title"})
40
38
  end
41
39
 
42
40
  it "allows additional attributes to be included in models" do
@@ -44,9 +42,7 @@ describe "configuration" do
44
42
  config.include_attributes :products => [:external_id, :url]
45
43
  end
46
44
 
47
- MadCart.config.included_attributes[:products].should == [:external_id, :url]
45
+ expect(MadCart.config.included_attributes[:products]).to eql([:external_id, :url])
48
46
  end
49
-
50
47
  end
51
-
52
48
  end
@@ -1,25 +1,25 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MadCart do
4
-
4
+
5
5
  it "allows configuration" do
6
6
  MadCart.configure do |config|
7
- config.should be_a(MadCart::Configuration)
8
- config.should be_a(Singleton)
7
+ expect(config).to be_a(MadCart::Configuration)
8
+ expect(config).to be_a(Singleton)
9
9
  end
10
10
  end
11
-
11
+
12
12
  it "provides config values" do
13
- MadCart.config.should be_a(MadCart::Configuration::Data)
13
+ expect(MadCart.config).to be_a(MadCart::Configuration::Data)
14
14
  end
15
-
15
+
16
16
  it "complains when the #config getter is used to set config values" do
17
- lambda do
17
+ expect {
18
18
  MadCart.config {|config| config.add_store :big_commerce }
19
- end.should raise_error(ArgumentError, "MadCart.config does not support blocks. Use MadCart.configure to set config values.")
19
+ }.to raise_error(ArgumentError, "MadCart.config does not support blocks. Use MadCart.configure to set config values.")
20
20
  end
21
-
21
+
22
22
  it "complains if #configure is used incorrectly" do
23
- lambda { MadCart.configure }.should raise_error(ArgumentError, "MadCart.configure requires a block argument.")
24
- end
25
- end
23
+ expect { MadCart.configure }.to raise_error(ArgumentError, "MadCart.configure requires a block argument.")
24
+ end
25
+ end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MadCart::Store::Base do
4
+
4
5
  before(:each) do
5
6
  clear_config
6
7
  Object.send(:remove_const, :MyModel) if Object.const_defined?(:MyModel)
@@ -15,35 +16,34 @@ describe MadCart::Store::Base do
15
16
  MadCart.configure do |config|
16
17
  config.include_attributes :my_models => [:external_id, :url]
17
18
  end
18
-
19
+
19
20
  o = MyModel.new(:name => 'whiskey', :description => 'tasty', :external_id => 2, :url => 'path/to/whiskey', :discarded => 'property')
20
- o.attributes.should == {"name" => 'whiskey', "description" => 'tasty', "external_id" => 2, "url" => 'path/to/whiskey'}
21
+ expect(o.attributes).to eql({"name" => 'whiskey', "description" => 'tasty', "external_id" => 2, "url" => 'path/to/whiskey'})
21
22
  end
22
-
23
+
23
24
  it "includes mapped attributes" do
24
25
  MadCart.configure do |config|
25
26
  config.attribute_map :my_models, :old_name => :new_name
26
27
  end
27
-
28
+
28
29
  o = MyModel.new(:name => 'whiskey', :description => 'tasty', :discarded => 'property', :old_name => 'is included')
29
- o.attributes.should == {"name" => 'whiskey', "description" => 'tasty', "new_name" => 'is included'}
30
+ expect(o.attributes).to eql({"name" => 'whiskey', "description" => 'tasty', "new_name" => 'is included'})
30
31
  end
31
-
32
+
32
33
  it "allows two sources to map to the same model" do
33
34
  MadCart.configure do |config|
34
35
  config.include_attributes :my_models => [:external_id]
35
36
  config.attribute_map :my_models, :id => :external_id
36
37
  end
37
-
38
+
38
39
  source_a = {:name => 'whiskey', :description => 'tasty', :discarded => 'property', :id => 'has been renamed'}
39
40
  source_b = {:name => 'whiskey', :description => 'tasty', :discarded => 'property', :external_id => 'is included'}
40
-
41
+
41
42
  model_a = MyModel.new(source_a)
42
- model_a.attributes.should == {"name" => 'whiskey', "description" => 'tasty', "external_id" => 'has been renamed'}
43
-
43
+ expect(model_a.attributes).to eql({"name" => 'whiskey', "description" => 'tasty', "external_id" => 'has been renamed'})
44
+
44
45
  model_b = MyModel.new(source_b)
45
- model_b.attributes.should == {"name" => 'whiskey', "description" => 'tasty', "external_id" => 'is included'}
46
+ expect(model_b.attributes).to eql({"name" => 'whiskey', "description" => 'tasty', "external_id" => 'is included'})
46
47
  end
47
48
  end
48
-
49
49
  end
@@ -10,7 +10,7 @@ describe MadCart::Model::Customer do
10
10
  attrs = {"first_name" => 'Bob', "last_name" => 'Sagat', "email" => 'bob@sagat.com'}
11
11
  c = MadCart::Model::Customer.new(attrs)
12
12
 
13
- c.attributes.should eql(attrs)
13
+ expect(c.attributes).to eql(attrs)
14
14
  end
15
15
 
16
16
  it "allows attributes to be overwritten" do
@@ -20,17 +20,16 @@ describe MadCart::Model::Customer do
20
20
 
21
21
  c = MadCart::Model::Customer.new(:first_name => 'Bob', :last_name => 'Sagat', :email => 'bob@sagat.com')
22
22
 
23
- c.attributes.should eql({"name" => 'Bob', "last_name" => 'Sagat', "email" => 'bob@sagat.com'})
23
+ expect(c.attributes).to eql({"name" => 'Bob', "last_name" => 'Sagat', "email" => 'bob@sagat.com'})
24
24
  end
25
25
 
26
26
  it "exposes all additional attributes provided by the api" do
27
27
  c = MadCart::Model::Customer.new("first_name" => 'Bob', "last_name" => 'Sagat', "email" => 'bob@sagat.com', "with" => 'some', "additional" => 'fields' )
28
28
 
29
- c.additional_attributes.should eql({"with" => 'some', "additional" => 'fields'})
29
+ expect(c.additional_attributes).to eql({"with" => 'some', "additional" => 'fields'})
30
30
  end
31
31
 
32
32
  describe "validation" do
33
-
34
33
  before(:each) do
35
34
  @args = {:first_name => 'first_name',
36
35
  :last_name => 'last_name',
@@ -40,19 +39,17 @@ describe MadCart::Model::Customer do
40
39
 
41
40
  it "requires first_name" do
42
41
  @args.delete(:first_name)
43
- lambda{ MadCart::Model::Customer.new(@args) }.should raise_error(ArgumentError)
42
+ expect { MadCart::Model::Customer.new(@args) }.to raise_error(ArgumentError)
44
43
  end
45
44
 
46
45
  it "requires last_name" do
47
46
  @args.delete(:last_name)
48
- lambda{ MadCart::Model::Customer.new(@args) }.should raise_error(ArgumentError)
47
+ expect { MadCart::Model::Customer.new(@args) }.to raise_error(ArgumentError)
49
48
  end
50
49
 
51
50
  it "requires email" do
52
51
  @args.delete(:email)
53
- lambda{ MadCart::Model::Customer.new(@args) }.should raise_error(ArgumentError)
52
+ expect { MadCart::Model::Customer.new(@args) }.to raise_error(ArgumentError)
54
53
  end
55
-
56
54
  end
57
-
58
55
  end
@@ -15,7 +15,7 @@ describe MadCart::Model::Product do
15
15
 
16
16
  c = MadCart::Model::Product.new(default_attrs.merge(extra_attrs))
17
17
 
18
- c.attributes.should eql(default_attrs)
18
+ expect(c.attributes).to eql(default_attrs)
19
19
  end
20
20
 
21
21
  it "allows attribute names to be overwritten" do
@@ -29,7 +29,7 @@ describe MadCart::Model::Product do
29
29
 
30
30
  c = MadCart::Model::Product.new(attrs.merge(:name => "product name", :square_image_url => 'path/to/square/image'))
31
31
 
32
- c.attributes.should eql(attrs.merge("title" => "product name",
32
+ expect(c.attributes).to eql(attrs.merge("title" => "product name",
33
33
  "thumbnail" => 'path/to/square/image'))
34
34
  end
35
35
 
@@ -39,11 +39,10 @@ describe MadCart::Model::Product do
39
39
 
40
40
  c = MadCart::Model::Product.new(attrs.merge(:with => 'some', :additional => 'fields'))
41
41
 
42
- c.additional_attributes.should eql({"with" => 'some', "additional" => 'fields'})
42
+ expect(c.additional_attributes).to eql({"with" => 'some', "additional" => 'fields'})
43
43
  end
44
44
 
45
45
  describe "validation" do
46
-
47
46
  before(:each) do
48
47
  @args = {:name => 'name',
49
48
  :external_id => 'external_id',
@@ -58,17 +57,17 @@ describe MadCart::Model::Product do
58
57
 
59
58
  it "requires name" do
60
59
  @args.delete(:name)
61
- lambda{ MadCart::Model::Product.new(@args) }.should raise_error(ArgumentError)
60
+ expect { MadCart::Model::Product.new(@args) }.to raise_error(ArgumentError)
62
61
  end
63
62
 
64
63
  it "requires description" do
65
64
  @args.delete(:description)
66
- lambda{ MadCart::Model::Product.new(@args) }.should raise_error(ArgumentError)
65
+ expect { MadCart::Model::Product.new(@args) }.to raise_error(ArgumentError)
67
66
  end
68
67
 
69
68
  it "requires image_url" do
70
69
  @args.delete(:image_url)
71
- lambda{ MadCart::Model::Product.new(@args) }.should raise_error(ArgumentError)
70
+ expect { MadCart::Model::Product.new(@args) }.to raise_error(ArgumentError)
72
71
  end
73
72
  end
74
73
  end
@@ -9,7 +9,7 @@ describe MadCart::Store::Base do
9
9
 
10
10
  describe "connection" do
11
11
  it "adds a create_connection_with method" do
12
- MyStore.should respond_to(:create_connection_with)
12
+ expect(MyStore).to respond_to(:create_connection_with)
13
13
  end
14
14
 
15
15
  it "accepts a method reference" do
@@ -21,7 +21,7 @@ describe MadCart::Store::Base do
21
21
  end
22
22
  end
23
23
 
24
- MyStore.new.connection.should == TestResult
24
+ expect(MyStore.new.connection).to eql(TestResult)
25
25
  end
26
26
 
27
27
  it "accepts a proc" do
@@ -29,7 +29,7 @@ describe MadCart::Store::Base do
29
29
  create_connection_with Proc.new {|args| TestResult }
30
30
  end
31
31
 
32
- MyStore.new.connection.should == TestResult
32
+ expect(MyStore.new.connection).to eql(TestResult)
33
33
  end
34
34
 
35
35
  it "raises an error if any required connection arguments are not present" do
@@ -37,7 +37,9 @@ describe MadCart::Store::Base do
37
37
  create_connection_with Proc.new { }, :requires => [:api_key, :username]
38
38
  end
39
39
 
40
- lambda { MyStore.new(:api_key => 'key').connection }.should raise_error(ArgumentError, "Missing connection arguments: username")
40
+ expect {
41
+ MyStore.new(:api_key => 'key').connection
42
+ }.to raise_error(ArgumentError, "Missing connection arguments: username")
41
43
  end
42
44
 
43
45
  it "retrieves configured connection arguments" do
@@ -49,7 +51,7 @@ describe MadCart::Store::Base do
49
51
  config.add_store :my_store, {:several => 'of', :args => 'yes?'}
50
52
  end
51
53
 
52
- lambda { MyStore.new().connection }.should_not raise_error
54
+ expect { MyStore.new().connection }.not_to raise_error
53
55
  end
54
56
 
55
57
  it "retrieves a combination of configured and initialised connection arguments" do
@@ -61,13 +63,13 @@ describe MadCart::Store::Base do
61
63
  config.add_store :my_store, {:several => 'only'}
62
64
  end
63
65
 
64
- lambda { MyStore.new(:args => 'too').connection }.should_not raise_error
66
+ expect { MyStore.new(:args => 'too').connection }.not_to raise_error
65
67
  end
66
68
  end
67
69
 
68
70
  describe "fetch" do
69
71
  it "adds a fetch method" do
70
- MyStore.should respond_to(:fetch)
72
+ expect(MyStore).to respond_to(:fetch)
71
73
  end
72
74
 
73
75
  it "accepts a method reference" do
@@ -80,8 +82,8 @@ describe MadCart::Store::Base do
80
82
  end
81
83
 
82
84
  result = double(MadCart::Model::Product)
83
- MadCart::Model::Product.should_receive(:new).with({:some => 'attrs'}).and_return(result)
84
- MyStore.new.products.should == [result]
85
+ expect(MadCart::Model::Product).to receive(:new).with({:some => 'attrs'}).and_return(result)
86
+ expect(MyStore.new.products).to eql([result])
85
87
  end
86
88
 
87
89
  it "accepts a proc" do
@@ -90,8 +92,8 @@ describe MadCart::Store::Base do
90
92
  end
91
93
 
92
94
  result = double(MadCart::Model::Product)
93
- MadCart::Model::Product.should_receive(:new).twice.with({:some => 'attrs'}).and_return(result)
94
- MyStore.new.products.should == [result, result]
95
+ expect(MadCart::Model::Product).to receive(:new).twice.with({:some => 'attrs'}).and_return(result)
96
+ expect(MyStore.new.products).to eql([result, result])
95
97
  end
96
98
 
97
99
  it "converts hashes into instances of the mad cart model" do
@@ -102,7 +104,7 @@ describe MadCart::Store::Base do
102
104
  fetch :products, :with => Proc.new { [attrs, attrs] }
103
105
  end
104
106
 
105
- MyStore.new.products.each{|p| p.should be_a(MadCart::Model::Product) }
107
+ MyStore.new.products.each { |p| expect(p).to be_a(MadCart::Model::Product) }
106
108
  end
107
109
 
108
110
  it "returns instances of the mad cart model if the fetch method returns them" do
@@ -113,7 +115,7 @@ describe MadCart::Store::Base do
113
115
  fetch :products, :with => Proc.new { [MadCart::Model::Product.new(attrs), MadCart::Model::Product.new(attrs)] }
114
116
  end
115
117
 
116
- MyStore.new.products.each{|p| p.should be_a(MadCart::Model::Product) }
118
+ MyStore.new.products.each { |p| expect(p).to be_a(MadCart::Model::Product) }
117
119
  end
118
120
 
119
121
  it "returns instances of the mad cart model if the format method returns them" do
@@ -125,7 +127,7 @@ describe MadCart::Store::Base do
125
127
  format :products, :with => Proc.new {|p| MadCart::Model::Product.new(p) }
126
128
  end
127
129
 
128
- MyStore.new.products.each{|p| p.should be_a(MadCart::Model::Product) }
130
+ MyStore.new.products.each { |p| expect(p).to be_a(MadCart::Model::Product) }
129
131
  end
130
132
 
131
133
  it "can be configured to retrieve additional attributes" do
@@ -141,7 +143,7 @@ describe MadCart::Store::Base do
141
143
 
142
144
  describe "format" do
143
145
  it "adds a format method" do
144
- MyStore.should respond_to(:format)
146
+ expect(MyStore).to respond_to(:format)
145
147
  end
146
148
 
147
149
  it "accepts a method reference" do
@@ -155,8 +157,8 @@ describe MadCart::Store::Base do
155
157
  end
156
158
 
157
159
  store = MyStore.new
158
- store.should_receive(:format_method).with(:one => 1).and_return(double(MadCart::Model::Product))
159
- store.stub(:ensure_model_format)
160
+ expect(store).to receive(:format_method).with(:one => 1).and_return(double(MadCart::Model::Product))
161
+ allow(store).to receive(:ensure_model_format)
160
162
  store.products
161
163
  end
162
164
 
@@ -167,7 +169,7 @@ describe MadCart::Store::Base do
167
169
  end
168
170
 
169
171
  store = MyStore.new
170
- store.should_receive(:ensure_model_format).with(:products, ["1"])
172
+ expect(store).to receive(:ensure_model_format).with(:products, ["1"])
171
173
  store.products
172
174
  end
173
175
  end
@@ -183,7 +185,7 @@ describe MadCart::Store::Base do
183
185
  end
184
186
 
185
187
  o = MyStore.new
186
- lambda { o.connection }.should raise_error(MadCart::Store::SetupError,
188
+ expect { o.connection }.to raise_error(MadCart::Store::SetupError,
187
189
  "It appears MyStore has overrided the default MadCart::Base initialize method. " +
188
190
  "That's fine, but please store any required connection arguments as @init_args " +
189
191
  "for the #connection method to use later. Remember to call #after_initialize " +
@@ -193,7 +195,7 @@ describe MadCart::Store::Base do
193
195
 
194
196
  describe "after_initialize" do
195
197
  it "adds an after_initialize method" do
196
- MyStore.should respond_to(:after_initialize)
198
+ expect(MyStore).to respond_to(:after_initialize)
197
199
  end
198
200
 
199
201
  it "accepts a method reference" do
@@ -210,7 +212,7 @@ describe MadCart::Store::Base do
210
212
  end
211
213
  end
212
214
 
213
- MyStore.new(:connection => TestResult).connection.should == TestResult
215
+ expect(MyStore.new(:connection => TestResult).connection).to eql(TestResult)
214
216
  end
215
217
 
216
218
  it "accepts a proc" do
@@ -223,7 +225,7 @@ describe MadCart::Store::Base do
223
225
  end
224
226
  end
225
227
 
226
- TestResult.should_receive(:new)
228
+ expect(TestResult).to receive(:new)
227
229
 
228
230
  MyStore.new(:connection => TestResult)
229
231
  end
@@ -11,85 +11,74 @@ describe MadCart::Store::BigCommerce do
11
11
  }
12
12
 
13
13
  describe "store" do
14
-
15
14
  it "expects to be instantiated with an api key, username and store url" do
16
- lambda { MadCart::Store::BigCommerce.new(:username => 'test', :store_url => 'test').connection }.should raise_error(ArgumentError)
17
- lambda { MadCart::Store::BigCommerce.new(:api_key => 'test', :username => 'test', :store_url => 'test').connection }.should_not raise_error
15
+ expect {
16
+ MadCart::Store::BigCommerce.new(:username => 'test', :store_url => 'test').connection
17
+ }.to raise_error(ArgumentError)
18
+ expect {
19
+ MadCart::Store::BigCommerce.new(:api_key => 'test', :username => 'test', :store_url => 'test').connection
20
+ }.not_to raise_error
18
21
  end
19
22
 
20
23
  it "authenticates via basic auth" do
21
- connection = Faraday.new
22
- Faraday.stub(:new).and_yield(connection)
23
-
24
- connection.should_receive(:basic_auth).with('username', 'api_key')
25
-
26
- MadCart::Store::BigCommerce.new(:api_key => 'api_key', :username => 'username', :store_url => 'url').connection
24
+ connection = MadCart::Store::BigCommerce.new(:api_key => 'api_key', :username => 'username', :store_url => 'url').connection
25
+ expect(connection.headers['Authorization']).not_to be_nil
27
26
  end
28
-
29
27
  end
30
28
 
31
29
  describe "products" do
32
-
33
30
  context "retrieval" do
34
-
35
31
  it "returns products" do
36
32
  VCR.use_cassette('big_commerce_products') do
37
33
  products = subject.products(limit: 10)
38
- products.size.should == 10
34
+ expect(products.size).to eql(10)
39
35
 
40
36
  first_product = products.first
41
- first_product.should be_a(MadCart::Model::Product)
42
- first_product.name.should_not be_nil
43
- first_product.description.should_not be_nil
44
- first_product.image_url.should_not be_nil
37
+ expect(first_product).to be_a(MadCart::Model::Product)
38
+ expect(first_product.name).not_to be_nil
39
+ expect(first_product.description).not_to be_nil
40
+ expect(first_product.image_url).not_to be_nil
45
41
  end
46
42
  end
47
43
 
48
44
  it "returns an empty array when there are no products" do
49
45
  VCR.use_cassette('big_commerce_no_records') do
50
- subject.products.should == []
46
+ expect(subject.products).to eql([])
51
47
  end
52
48
  end
53
49
 
54
-
55
50
  it "returns an empty array when there are no images for any products" do
56
51
  VCR.use_cassette('big_commerce_products_no_images') do
57
- subject.products.should == []
52
+ expect(subject.products).to eql([])
58
53
  end
59
54
  end
60
-
61
55
  end
62
56
 
63
57
  context "count" do
64
-
65
58
  it "returns how many products there are" do
66
59
  VCR.use_cassette('big_commerce_products_count') do
67
- subject.products_count.should == 45
60
+ expect(subject.products_count).to eql(45)
68
61
  end
69
62
  end
70
-
71
63
  end
72
-
73
64
  end
74
65
 
75
66
  describe "customers" do
76
67
  context "retrieval" do
77
-
78
68
  it "returns all customers" do
79
69
  VCR.use_cassette('big_commerce_customers') do
80
70
  customers = subject.customers
81
71
 
82
- customers.size.should be > 0
83
- customers.first.should be_a(MadCart::Model::Customer)
72
+ expect(customers.size).to be > 0
73
+ expect(customers.first).to be_a(MadCart::Model::Customer)
84
74
  end
85
75
  end
86
76
 
87
77
  it "returns an empty array whern there are no customers" do
88
78
  VCR.use_cassette('big_commerce_no_records') do
89
- subject.customers.should eql([])
79
+ expect(subject.customers).to eql([])
90
80
  end
91
81
  end
92
-
93
82
  end
94
83
  end
95
84
 
@@ -97,17 +86,16 @@ describe MadCart::Store::BigCommerce do
97
86
  context "retrieval" do
98
87
  it "returns the store" do
99
88
  VCR.use_cassette('big_commerce_store') do
100
- subject.store.should_not be_nil
89
+ expect(subject.store).not_to be_nil
101
90
  end
102
91
  end
103
92
  end
104
93
  end
105
94
 
106
95
  describe "validating credentials" do
107
-
108
96
  it "succeeds if it can get time.json from big commerce" do
109
97
  VCR.use_cassette('big_commerce_time') do
110
- subject.should be_valid
98
+ expect(subject).to be_valid
111
99
  end
112
100
  end
113
101
 
@@ -119,7 +107,7 @@ describe MadCart::Store::BigCommerce do
119
107
  :username => 'support@madmimi.com'
120
108
  )
121
109
 
122
- api.should_not be_valid
110
+ expect(api).not_to be_valid
123
111
  end
124
112
  end
125
113
 
@@ -131,16 +119,15 @@ describe MadCart::Store::BigCommerce do
131
119
  :username => 'support@madmimi.com'
132
120
  )
133
121
 
134
- api.should_not be_valid
122
+ expect(api).not_to be_valid
135
123
  end
136
124
  end
137
125
 
138
126
  it "fails if it cannot parse the response from the big commerce server" do
139
127
  VCR.use_cassette('big_commerce_time') do
140
- subject.connection.stub(:get) { raise Faraday::ParsingError, "" }
141
- subject.should_not be_valid
128
+ allow(subject.connection).to receive(:get).and_raise(Faraday::ParsingError.new(""))
129
+ expect(subject).not_to be_valid
142
130
  end
143
131
  end
144
132
  end
145
-
146
133
  end
@@ -5,7 +5,6 @@ describe MadCart::Store::Etsy do
5
5
  before(:each) { clear_config }
6
6
 
7
7
  describe "retrieving products" do
8
-
9
8
  context "the store doesn't exist" do
10
9
  let(:invalid_store_name) { 'MadeUpStore' }
11
10
  let(:store) { MadCart::Store::Etsy.new(:store_name => invalid_store_name, :api_key => '4j3amz573gly866229iixzri') }
@@ -18,7 +17,6 @@ describe MadCart::Store::Etsy do
18
17
  end
19
18
 
20
19
  context "the store does exist" do
21
-
22
20
  before(:each) do
23
21
  MadCart.configure do |config|
24
22
  config.add_store :etsy, {:api_key => '4j3amz573gly866229iixzri'}
@@ -29,16 +27,15 @@ describe MadCart::Store::Etsy do
29
27
  VCR.use_cassette('etsy_store_listings') do
30
28
  api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
31
29
  products = api.products(:includes => "MainImage")
32
- products.size.should == 25 # the etsy product limit
30
+ expect(products.size).to eql(25) # the etsy product limit
33
31
 
34
32
  first_product = products.first
35
33
 
36
- first_product.should be_a(MadCart::Model::Product)
37
- first_product.name.should_not be_nil
38
- first_product.description.should_not be_nil
39
- first_product.image_url.should_not be_nil
40
- puts first_product.image_url
41
- first_product.additional_attributes['price'].should == BigDecimal.new('2.5')
34
+ expect(first_product).to be_a(MadCart::Model::Product)
35
+ expect(first_product.name).not_to be_nil
36
+ expect(first_product.description).not_to be_nil
37
+ expect(first_product.image_url).not_to be_nil
38
+ expect(first_product.additional_attributes['price']).to eql(BigDecimal.new('2.5'))
42
39
  end
43
40
  end
44
41
 
@@ -47,26 +44,25 @@ describe MadCart::Store::Etsy do
47
44
  VCR.use_cassette('etsy_store_listings_new_format_image') do
48
45
  api = MadCart::Store::Etsy.new(:store_name => 'TheBeadsofDreams')
49
46
  products = api.products(:includes => "MainImage")
50
- products.size.should == 25 # the etsy product limit
47
+ expect(products.size).to eql(25) # the etsy product limit
51
48
 
52
49
  first_product = products.first
53
50
 
54
- first_product.should be_a(MadCart::Model::Product)
55
- first_product.name.should_not be_nil
56
- first_product.description.should_not be_nil
57
- first_product.image_url.should_not be_nil
58
- first_product.additional_attributes['price'].should == BigDecimal.new('2.2')
51
+ expect(first_product).to be_a(MadCart::Model::Product)
52
+ expect(first_product.name).not_to be_nil
53
+ expect(first_product.description).not_to be_nil
54
+ expect(first_product.image_url).not_to be_nil
55
+ expect(first_product.additional_attributes['price']).to eql(BigDecimal.new('2.2'))
59
56
  end
60
57
  end
61
58
  end
62
59
 
63
60
  context "pagination" do
64
-
65
61
  it "defaults to page one" do
66
62
  VCR.use_cassette('etsy_store_listings') do
67
63
  api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
68
64
 
69
- api.connection.should_receive(:listings).with(:active, {:page => 1}).and_return([])
65
+ expect(api.connection).to receive(:listings).with(:active, {:page => 1}).and_return([])
70
66
  api.products
71
67
  end
72
68
  end
@@ -75,37 +71,31 @@ describe MadCart::Store::Etsy do
75
71
  VCR.use_cassette('etsy_store_listings') do
76
72
  api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
77
73
 
78
- api.connection.should_receive(:listings).with(:active, {:page => 2}).and_return([]) # Trusting the Etsy gem, not testing that it works
74
+ expect(api.connection).to receive(:listings).with(:active, {:page => 2}).and_return([]) # Trusting the Etsy gem, not testing that it works
79
75
  api.products(:page => 2)
80
76
  end
81
77
  end
82
-
83
78
  end
84
79
 
85
80
  context "validating credentials" do
86
-
87
81
  it "succeeds if it can get a connection object" do
88
82
  VCR.use_cassette('etsy_store_listings') do
89
83
  api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
90
84
 
91
- api.should be_valid
85
+ expect(api).to be_valid
92
86
  end
93
87
  end
94
88
 
95
89
  it "fails if it cannot get a connection object" do
96
90
  VCR.use_cassette('etsy_store_listings') do
97
91
  api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
98
- api.stub(:create_connection).and_return(nil)
92
+ allow(api).to receive(:create_connection).and_return(nil)
99
93
 
100
- api.should_not be_valid
94
+ expect(api).not_to be_valid
101
95
  end
102
96
  end
103
-
104
97
  end
105
-
106
98
  end
107
-
108
99
  end
109
-
110
100
  end
111
101
 
@@ -30,7 +30,7 @@ describe MadCart::Store::OAuthBigCommerce do
30
30
  context "retrieval" do
31
31
  it "returns the store" do
32
32
  VCR.use_cassette('o_auth_big_commerce_store') do
33
- subject.store.should_not be_nil
33
+ expect(subject.store).not_to be_nil
34
34
  end
35
35
  end
36
36
  end
@@ -22,32 +22,28 @@ describe MadCart::Store::Spree do
22
22
  }
23
23
 
24
24
  describe "store" do
25
-
26
25
  it "expects to be instantiated with an api key and store url" do
27
- lambda { MadCart::Store::Spree.new(:store_url => 'test').connection }.should raise_error(ArgumentError)
28
- lambda { MadCart::Store::Spree.new(:api_key => 'test', :store_url => 'test').connection }.should_not raise_error
26
+ expect { MadCart::Store::Spree.new(:store_url => 'test').connection }.to raise_error(ArgumentError)
27
+ expect { MadCart::Store::Spree.new(:api_key => 'test', :store_url => 'test').connection }.not_to raise_error
29
28
  end
30
-
31
29
  end
32
30
 
33
31
  describe "products" do
34
-
35
32
  context "retrieval" do
36
-
37
33
  context "basic spree installation" do
38
34
  it "returns all products" do
39
35
  VCR.use_cassette(spree_cassette, :record => :new_episodes) do
40
36
  api = MadCart::Store::Spree.new(valid_credentials)
41
37
 
42
- api.products.size.should == 58
38
+ expect(api.products.size).to eql(58)
43
39
 
44
40
  first_product = api.products.first
45
41
 
46
- first_product.should be_a(MadCart::Model::Product)
47
- first_product.name.should_not be_nil
48
- first_product.description.should_not be_nil
49
- first_product.image_url.should_not be_nil
50
- first_product.additional_attributes['price'].should_not be_nil
42
+ expect(first_product).to be_a(MadCart::Model::Product)
43
+ expect(first_product.name).not_to be_nil
44
+ expect(first_product.description).not_to be_nil
45
+ expect(first_product.image_url).not_to be_nil
46
+ expect(first_product.additional_attributes['price']).not_to be_nil
51
47
  end
52
48
  end
53
49
  end
@@ -57,15 +53,15 @@ describe MadCart::Store::Spree do
57
53
  VCR.use_cassette(spree_alternative_cassette, :record => :new_episodes) do
58
54
  api = MadCart::Store::Spree.new(valid_alternative_credentials)
59
55
 
60
- api.products.size.should == 148
56
+ expect(api.products.size).to eql(148)
61
57
 
62
58
  first_product = api.products.first
63
59
 
64
- first_product.should be_a(MadCart::Model::Product)
65
- first_product.name.should_not be_nil
66
- first_product.description.should_not be_nil
67
- first_product.image_url.should_not be_nil
68
- first_product.additional_attributes['price'].should_not be_nil
60
+ expect(first_product).to be_a(MadCart::Model::Product)
61
+ expect(first_product.name).not_to be_nil
62
+ expect(first_product.description).not_to be_nil
63
+ expect(first_product.image_url).not_to be_nil
64
+ expect(first_product.additional_attributes['price']).not_to be_nil
69
65
  end
70
66
  end
71
67
  end
@@ -73,7 +69,7 @@ describe MadCart::Store::Spree do
73
69
  it "returns an empty array when there are no products" do
74
70
  VCR.use_cassette(spree_no_records_cassette) do
75
71
  api = MadCart::Store::Spree.new(valid_credentials)
76
- api.products.should == []
72
+ expect(api.products).to eql([])
77
73
  end
78
74
  end
79
75
 
@@ -84,7 +80,7 @@ describe MadCart::Store::Spree do
84
80
  it "returns how many products there are" do
85
81
  VCR.use_cassette(spree_cassette, :record => :new_episodes) do
86
82
  api = MadCart::Store::Spree.new(valid_credentials)
87
- api.products_count.should == 58
83
+ expect(api.products_count).to eql(58)
88
84
  end
89
85
  end
90
86
 
@@ -99,8 +95,8 @@ describe MadCart::Store::Spree do
99
95
  VCR.use_cassette(spree_cassette, :record => :new_episodes) do
100
96
  api = MadCart::Store::Spree.new(valid_credentials)
101
97
 
102
- api.customers.size.should be > 0
103
- api.customers.first.should be_a(MadCart::Model::Customer)
98
+ expect(api.customers.size).to be > 0
99
+ expect(api.customers.first).to be_a(MadCart::Model::Customer)
104
100
  end
105
101
  end
106
102
 
@@ -108,19 +104,18 @@ describe MadCart::Store::Spree do
108
104
  VCR.use_cassette(spree_no_records_cassette) do
109
105
  api = MadCart::Store::Spree.new(valid_credentials)
110
106
 
111
- api.customers.should eql([])
107
+ expect(api.customers).to eql([])
112
108
  end
113
109
  end
114
110
 
115
111
  end
116
112
 
117
113
  describe "validating credentials" do
118
-
119
114
  it "succeeds if it can get orders.json from Spree" do
120
115
  VCR.use_cassette(spree_cassette, :record => :new_episodes) do
121
116
  api = MadCart::Store::Spree.new(valid_credentials)
122
117
 
123
- api.should be_valid
118
+ expect(api).to be_valid
124
119
  end
125
120
  end
126
121
 
@@ -131,11 +126,9 @@ describe MadCart::Store::Spree do
131
126
  :store_url => valid_credentials[:store_url]
132
127
  )
133
128
 
134
- api.should_not be_valid
129
+ expect(api).not_to be_valid
135
130
  end
136
131
  end
137
-
138
132
  end
139
133
  end
140
-
141
134
  end
@@ -14,7 +14,6 @@ require 'vcr'
14
14
  require 'webmock/rspec'
15
15
 
16
16
  RSpec.configure do |config|
17
- config.treat_symbols_as_metadata_keys_with_true_values = true
18
17
  config.run_all_when_everything_filtered = true
19
18
  config.filter_run :focus
20
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mad_cart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Heiligers
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-01 00:00:00.000000000 Z
13
+ date: 2017-12-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -203,6 +203,7 @@ extra_rdoc_files: []
203
203
  files:
204
204
  - ".gitignore"
205
205
  - ".rspec"
206
+ - ".travis.yml"
206
207
  - CHANGELOG.md
207
208
  - Gemfile
208
209
  - LICENSE.txt