mad_cart 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ require "spec_helper"
2
+
3
+ describe MadCart::Store::Etsy do
4
+
5
+ before(:each) { clear_config }
6
+
7
+ describe "retrieving products" do
8
+
9
+ context "the store doesn't exist" do
10
+ let(:invalid_store_name) { 'MadeUpStore' }
11
+ let(:store) { MadCart::Store::Etsy.new(:store_name => invalid_store_name, :api_key => '4j3amz573gly866229iixzri') }
12
+
13
+ it "raises an exception" do
14
+ VCR.use_cassette('etsy_store_listings') do
15
+ expect { store.products }.to raise_exception MadCart::Store::InvalidStore
16
+ end
17
+ end
18
+ end
19
+
20
+ context "the store does exist" do
21
+
22
+ before(:each) do
23
+ MadCart.configure do |config|
24
+ config.add_store :etsy, {:api_key => '4j3amz573gly866229iixzri'}
25
+ end
26
+ end
27
+
28
+ it "returns products" do
29
+ VCR.use_cassette('etsy_store_listings') do
30
+ api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
31
+ products = api.products(:includes => "MainImage")
32
+ products.size.should == 25 # the etsy product limit
33
+
34
+ first_product = products.first
35
+
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
+ end
41
+ end
42
+
43
+ context "pagination" do
44
+
45
+ it "defaults to page one" do
46
+ VCR.use_cassette('etsy_store_listings') do
47
+ api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
48
+
49
+ api.connection.should_receive(:listings).with(:active, {:page => 1}).and_return([])
50
+ api.products
51
+ end
52
+ end
53
+
54
+ it "returns the page requested" do
55
+ VCR.use_cassette('etsy_store_listings') do
56
+ api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
57
+
58
+ api.connection.should_receive(:listings).with(:active, {:page => 2}).and_return([]) # Trusting the Etsy gem, not testing that it works
59
+ api.products(:page => 2)
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ context "validating credentials" do
66
+
67
+ it "succeeds if it can get a connection object" do
68
+ VCR.use_cassette('etsy_store_listings') do
69
+ api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
70
+
71
+ api.should be_valid
72
+ end
73
+ end
74
+
75
+ it "fails if it cannot get a connection object" do
76
+ VCR.use_cassette('etsy_store_listings') do
77
+ api = MadCart::Store::Etsy.new(:store_name => 'FabBeads')
78
+ api.stub(:create_connection).and_return(nil)
79
+
80
+ api.should_not be_valid
81
+ end
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
@@ -0,0 +1,42 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'simplecov'
8
+ SimpleCov.start do
9
+ add_filter "/vendor/"
10
+ end
11
+
12
+ require "mad_cart"
13
+ require 'vcr'
14
+ require 'webmock/rspec'
15
+
16
+ RSpec.configure do |config|
17
+ config.treat_symbols_as_metadata_keys_with_true_values = true
18
+ config.run_all_when_everything_filtered = true
19
+ config.filter_run :focus
20
+
21
+ # Run specs in random order to surface order dependencies. If you find an
22
+ # order dependency and want to debug it, you can fix the order by providing
23
+ # the seed, which is printed after each run.
24
+ # --seed 1234
25
+ config.order = 'random'
26
+
27
+ config.include WebMock::API
28
+ end
29
+
30
+ VCR.configure do |c|
31
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
32
+ c.hook_into :webmock
33
+ #c.default_cassette_options = { :record => :new_episodes }
34
+ #c.debug_logger = File.open('vcr.log', 'w')
35
+ end
36
+
37
+
38
+ # helper methods
39
+ def clear_config
40
+ # Re-initialize the MadCart::Configuration singleton instance
41
+ Singleton.__init__(MadCart::Configuration)
42
+ end
metadata ADDED
@@ -0,0 +1,284 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mad_cart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marc Heiligers
9
+ - Stuart Corbishley
10
+ - Nic Young
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-08-01 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: faraday
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: faraday_middleware
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.3'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '1.3'
64
+ - !ruby/object:Gem::Dependency
65
+ name: rake
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: json
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 1.7.7
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: 1.7.7
96
+ - !ruby/object:Gem::Dependency
97
+ name: rspec
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: vcr
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - '='
118
+ - !ruby/object:Gem::Version
119
+ version: 2.5.0
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - '='
126
+ - !ruby/object:Gem::Version
127
+ version: 2.5.0
128
+ - !ruby/object:Gem::Dependency
129
+ name: webmock
130
+ requirement: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ version: 1.11.0
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: 1.11.0
144
+ - !ruby/object:Gem::Dependency
145
+ name: simplecov
146
+ requirement: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: etsy
162
+ requirement: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - '='
166
+ - !ruby/object:Gem::Version
167
+ version: 0.2.1
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - '='
174
+ - !ruby/object:Gem::Version
175
+ version: 0.2.1
176
+ - !ruby/object:Gem::Dependency
177
+ name: money
178
+ requirement: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ - !ruby/object:Gem::Dependency
193
+ name: activesupport
194
+ requirement: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ~>
198
+ - !ruby/object:Gem::Version
199
+ version: '3.2'
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ~>
206
+ - !ruby/object:Gem::Version
207
+ version: '3.2'
208
+ description: Provides a unified api for various e-commerce merchants.
209
+ email:
210
+ - ''
211
+ executables: []
212
+ extensions: []
213
+ extra_rdoc_files: []
214
+ files:
215
+ - .gitignore
216
+ - .rspec
217
+ - Gemfile
218
+ - LICENSE.txt
219
+ - README.md
220
+ - Rakefile
221
+ - lib/mad_cart.rb
222
+ - lib/mad_cart/attribute_mapper.rb
223
+ - lib/mad_cart/configuration.rb
224
+ - lib/mad_cart/inheritable_attributes.rb
225
+ - lib/mad_cart/model/base.rb
226
+ - lib/mad_cart/model/customer.rb
227
+ - lib/mad_cart/model/product.rb
228
+ - lib/mad_cart/store/base.rb
229
+ - lib/mad_cart/store/big_commerce.rb
230
+ - lib/mad_cart/store/etsy.rb
231
+ - lib/mad_cart/version.rb
232
+ - mad_cart.gemspec
233
+ - spec/fixtures/vcr_cassettes/big_commerce.yml
234
+ - spec/fixtures/vcr_cassettes/big_commerce_no_records.yml
235
+ - spec/fixtures/vcr_cassettes/etsy_store_listings.yml
236
+ - spec/lib/configuration_spec.rb
237
+ - spec/lib/mad_cart_spec.rb
238
+ - spec/lib/model/base_spec.rb
239
+ - spec/lib/model/customer_spec.rb
240
+ - spec/lib/model/product_spec.rb
241
+ - spec/lib/store/base_spec.rb
242
+ - spec/lib/store/big_commerce_spec.rb
243
+ - spec/lib/store/etsy_spec.rb
244
+ - spec/spec_helper.rb
245
+ homepage: https://github.com/madmimi/mad_cart
246
+ licenses:
247
+ - MIT
248
+ post_install_message:
249
+ rdoc_options: []
250
+ require_paths:
251
+ - lib
252
+ required_ruby_version: !ruby/object:Gem::Requirement
253
+ none: false
254
+ requirements:
255
+ - - ! '>='
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ required_rubygems_version: !ruby/object:Gem::Requirement
259
+ none: false
260
+ requirements:
261
+ - - ! '>='
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ requirements: []
265
+ rubyforge_project:
266
+ rubygems_version: 1.8.25
267
+ signing_key:
268
+ specification_version: 3
269
+ summary: Allows communication with various e-commerce merchants such as BigCommerce
270
+ and Etsy through a single gem. Extensible to allow the easy addition of merchants
271
+ and functionality.
272
+ test_files:
273
+ - spec/fixtures/vcr_cassettes/big_commerce.yml
274
+ - spec/fixtures/vcr_cassettes/big_commerce_no_records.yml
275
+ - spec/fixtures/vcr_cassettes/etsy_store_listings.yml
276
+ - spec/lib/configuration_spec.rb
277
+ - spec/lib/mad_cart_spec.rb
278
+ - spec/lib/model/base_spec.rb
279
+ - spec/lib/model/customer_spec.rb
280
+ - spec/lib/model/product_spec.rb
281
+ - spec/lib/store/base_spec.rb
282
+ - spec/lib/store/big_commerce_spec.rb
283
+ - spec/lib/store/etsy_spec.rb
284
+ - spec/spec_helper.rb