bigcartel 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,225 +1,225 @@
1
- require 'helper'
2
-
3
- describe BigCartel do
4
- before do
5
-
6
- stub_request(:get, "api.bigcartel.com/park/store.js").
7
- to_return(:body=>fixture("store.json"), :headers => {:content_type => "application/json; charset=utf-8"})
8
-
9
- stub_request(:get, /api.bigcartel.com\/park\/products.js/).
10
- to_return(:body=>fixture("products.json"), :headers => {:content_type => "application/json; charset=utf-8"})
11
-
12
- stub_request(:get, /api.bigcartel.com\/park\/page\/\w+.js/).
13
- to_return(:body=>fixture("page.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
- end
15
-
16
- it "will delegate BigCartel.new to client " do
17
- client = BigCartel.new
18
- client.should be_an_instance_of BigCartel::Client
19
- end
20
-
21
- end
22
-
23
-
24
- describe BigCartel::Client do
25
-
26
- before do
27
-
28
- stub_request(:get, "api.bigcartel.com/park/store.js").
29
- to_return(:body=>fixture("store.json"), :headers => {:content_type => "application/json; charset=utf-8"})
30
-
31
- stub_request(:get, /api.bigcartel.com\/park\/products.js\?limit=\d+/).
32
- to_return(:body=>fixture("products.json"), :headers => {:content_type => "application/json; charset=utf-8"})
33
-
34
- stub_request(:get, /api.bigcartel.com\/park\/page\/\w+.js/).
35
- to_return(:body=>fixture("page.json"), :headers => {:content_type => "application/json; charset=utf-8"})
36
- end
37
-
38
-
39
- #base client features
40
- describe "client" do
41
-
42
- before(:each) do
43
- @client = BigCartel::Client.new
44
- end
45
-
46
- it "is properly classed" do
47
- @client.should be_an_instance_of BigCartel::Client
48
- end
49
-
50
- it "can fetch" do
51
- store = BigCartel::Client.fetch("/park/store.js")
52
- a_request(:get, "api.bigcartel.com/park/store.js").
53
- should have_been_made
54
- end
55
-
56
- it "can list" do
57
- store = BigCartel::Client.list("/park/products.js", {:limit => 100})
58
- a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
59
- should have_been_made
60
- end
61
- end
62
-
63
- #########################################
64
- #store features
65
- describe ".store" do
66
- before do
67
- @client = BigCartel::Client.new
68
- end
69
-
70
- it "with no options makes 1 http call" do
71
- store = @client.store("park")
72
- a_request(:get, "api.bigcartel.com/park/store.js").
73
- should have_been_made
74
-
75
- a_request(:get, /api.bigcartel.com\/park\/products.js/).
76
- should have_been_made
77
- end
78
-
79
- it "with show_products makes 2 http call" do
80
- store = @client.store("park", {:show_products => true, :product_limit => 2})
81
- a_request(:get, "api.bigcartel.com/park/store.js").
82
- should have_been_made
83
-
84
- a_request(:get, "api.bigcartel.com/park/products.js?limit=2").
85
- should have_been_made
86
- end
87
-
88
- it "with show_products false makes 1 http call" do
89
- store = @client.store("park", {:show_products => false, :product_limit => 2})
90
- a_request(:get, "api.bigcartel.com/park/store.js").
91
- should have_been_made
92
-
93
- a_request(:get, "api.bigcartel.com/park/products.js?limit=2").
94
- should_not have_been_made
95
- end
96
-
97
- context "will be a valid hash" do
98
- before{@store = @client.store("park")}
99
-
100
- it {@store.should be_a Hash}
101
-
102
- it "should have a url" do
103
- @store.url.should be_an String
104
- @store.url.should eq("http://park.bigcartel.com")
105
- end
106
-
107
- it "should have an account label" do
108
- @store.account.should be_an String
109
- @store.account.should eq("park")
110
- end
111
-
112
- it { @store.categories.should be_an Array }
113
- it { @store.artists.should be_an Array }
114
- it { @store.website.should be_a String }
115
- it { @store.description.should be_a String }
116
- it { @store.name.should be_a String }
117
- it { @store.products_count.should be_an Integer }
118
- it { @store.country.should be_an Hash }
119
- it { @store.currency.should be_an Hash }
120
- it { @store.pages.should be_an Array }
121
- it { @store.products.should be_a Array }
122
- end
123
-
124
- end
125
-
126
-
127
- #########################################
128
- # product methods
129
-
130
- describe ".products" do
131
- before do
132
- @client = BigCartel::Client.new
133
- end
134
-
135
- it "will make http api calls" do
136
- products = @client.products("park")
137
- a_request(:get, "api.bigcartel.com/park/store.js").
138
- should_not have_been_made
139
-
140
- a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
141
- should have_been_made
142
- end
143
-
144
- it "accepts limit parameter" do
145
- products = @client.products("park", {:limit => 10} )
146
-
147
- a_request(:get, "api.bigcartel.com/park/products.js?limit=10").
148
- should have_been_made
149
- end
150
-
151
- context "will be a valid hash" do
152
- before{@product = @client.products("park").first}
153
-
154
- it {@product.should be_a Hash}
155
-
156
- it "should have a permalink" do
157
- @product.permalink.should be_an String
158
- @product.permalink.should eq("watch-test")
159
- end
160
-
161
- it { @product.tax.should be_an Float }
162
- it { @product.created_at.should be_a String }
163
- it { @product.shipping.should be_an Array }
164
- it { @product.status.should be_a String }
165
- it { @product.artists.should be_an Array }
166
- it { @product.categories.should be_an Array }
167
- it { @product.position.should be_an Integer }
168
- it { @product.images.should be_an Array }
169
- it { @product.images.first.thumb.should be_a String }
170
- it { @product.images.first.medium.should be_a String }
171
- it { @product.images.first.large.should be_a String }
172
-
173
- it { @product.on_sale.should eq(!!@product.on_sale) } #Boolean test
174
- it { @product.description.should be_a String }
175
- it { @product.price.should be_an Float }
176
- it { @product.name.should be_a String }
177
- it { @product.url.should be_a String }
178
- it { @product.default_price.should be_a Float }
179
- it { @product.id.should be_an Integer }
180
- it { @product.options.should be_an Array }
181
-
182
- end
183
-
184
- end
185
-
186
- ##################
187
- describe ".page" do
188
- before do
189
- @client = BigCartel::Client.new
190
- end
191
-
192
- it "will make http api calls" do
193
- page = @client.page("park", "about")
194
- a_request(:get, "api.bigcartel.com/park/page/about.js").
195
- should have_been_made
196
-
197
- a_request(:get, "api.bigcartel.com/park/store.js").
198
- should_not have_been_made
199
-
200
- a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
201
- should_not have_been_made
202
- end
203
-
204
- describe 'should build hash' do
205
- before(:each) { @page = @client.page("park", "about")}
206
-
207
- it "should have a permalink" do
208
- @page.permalink.should be_a String
209
- @page.permalink.should eq("about")
210
- end
211
-
212
- it { @page.content.should be_a String }
213
- it { @page.category.should be_a String }
214
- it { @page.name.should be_a String }
215
- it { @page.url.should be_a String }
216
- it { @page.id.should be_an Integer }
217
- end
218
-
219
- end
220
-
221
-
222
-
223
-
224
-
225
- end
1
+ require 'helper'
2
+
3
+ describe BigCartel do
4
+ before do
5
+
6
+ stub_request(:get, "api.bigcartel.com/park/store.js").
7
+ to_return(:body=>fixture("store.json"), :headers => {:content_type => "application/json; charset=utf-8"})
8
+
9
+ stub_request(:get, /api.bigcartel.com\/park\/products.js/).
10
+ to_return(:body=>fixture("products.json"), :headers => {:content_type => "application/json; charset=utf-8"})
11
+
12
+ stub_request(:get, /api.bigcartel.com\/park\/page\/\w+.js/).
13
+ to_return(:body=>fixture("page.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+
16
+ it "will delegate BigCartel.new to client " do
17
+ client = BigCartel.new
18
+ client.should be_an_instance_of BigCartel::Client
19
+ end
20
+
21
+ end
22
+
23
+
24
+ describe BigCartel::Client do
25
+
26
+ before do
27
+
28
+ stub_request(:get, "api.bigcartel.com/park/store.js").
29
+ to_return(:body=>fixture("store.json"), :headers => {:content_type => "application/json; charset=utf-8"})
30
+
31
+ stub_request(:get, /api.bigcartel.com\/park\/products.js\?limit=\d+/).
32
+ to_return(:body=>fixture("products.json"), :headers => {:content_type => "application/json; charset=utf-8"})
33
+
34
+ stub_request(:get, /api.bigcartel.com\/park\/page\/\w+.js/).
35
+ to_return(:body=>fixture("page.json"), :headers => {:content_type => "application/json; charset=utf-8"})
36
+ end
37
+
38
+
39
+ #base client features
40
+ describe "client" do
41
+
42
+ before(:each) do
43
+ @client = BigCartel::Client.new
44
+ end
45
+
46
+ it "is properly classed" do
47
+ @client.should be_an_instance_of BigCartel::Client
48
+ end
49
+
50
+ it "can fetch" do
51
+ store = BigCartel::Client.fetch("/park/store.js")
52
+ a_request(:get, "api.bigcartel.com/park/store.js").
53
+ should have_been_made
54
+ end
55
+
56
+ it "can list" do
57
+ store = BigCartel::Client.list("/park/products.js", {:limit => 100})
58
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
59
+ should have_been_made
60
+ end
61
+ end
62
+
63
+ #########################################
64
+ #store features
65
+ describe ".store" do
66
+ before do
67
+ @client = BigCartel::Client.new
68
+ end
69
+
70
+ it "with no options makes 1 http call" do
71
+ store = @client.store("park")
72
+ a_request(:get, "api.bigcartel.com/park/store.js").
73
+ should have_been_made
74
+
75
+ a_request(:get, /api.bigcartel.com\/park\/products.js/).
76
+ should have_been_made
77
+ end
78
+
79
+ it "with show_products makes 2 http call" do
80
+ store = @client.store("park", {:show_products => true, :product_limit => 2})
81
+ a_request(:get, "api.bigcartel.com/park/store.js").
82
+ should have_been_made
83
+
84
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=2").
85
+ should have_been_made
86
+ end
87
+
88
+ it "with show_products false makes 1 http call" do
89
+ store = @client.store("park", {:show_products => false, :product_limit => 2})
90
+ a_request(:get, "api.bigcartel.com/park/store.js").
91
+ should have_been_made
92
+
93
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=2").
94
+ should_not have_been_made
95
+ end
96
+
97
+ context "will be a valid hash" do
98
+ before{@store = @client.store("park")}
99
+
100
+ it {@store.should be_a Hash}
101
+
102
+ it "should have a url" do
103
+ @store.url.should be_an String
104
+ @store.url.should eq("http://park.bigcartel.com")
105
+ end
106
+
107
+ it "should have an account label" do
108
+ @store.account.should be_an String
109
+ @store.account.should eq("park")
110
+ end
111
+
112
+ it { @store.categories.should be_an Array }
113
+ it { @store.artists.should be_an Array }
114
+ it { @store.website.should be_a String }
115
+ it { @store.description.should be_a String }
116
+ it { @store.name.should be_a String }
117
+ it { @store.products_count.should be_an Integer }
118
+ it { @store.country.should be_an Hash }
119
+ it { @store.currency.should be_an Hash }
120
+ it { @store.pages.should be_an Array }
121
+ it { @store.products.should be_a Array }
122
+ end
123
+
124
+ end
125
+
126
+
127
+ #########################################
128
+ # product methods
129
+
130
+ describe ".products" do
131
+ before do
132
+ @client = BigCartel::Client.new
133
+ end
134
+
135
+ it "will make http api calls" do
136
+ products = @client.products("park")
137
+ a_request(:get, "api.bigcartel.com/park/store.js").
138
+ should_not have_been_made
139
+
140
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
141
+ should have_been_made
142
+ end
143
+
144
+ it "accepts limit parameter" do
145
+ products = @client.products("park", {:limit => 10} )
146
+
147
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=10").
148
+ should have_been_made
149
+ end
150
+
151
+ context "will be a valid hash" do
152
+ before{@product = @client.products("park").first}
153
+
154
+ it {@product.should be_a Hash}
155
+
156
+ it "should have a permalink" do
157
+ @product.permalink.should be_an String
158
+ @product.permalink.should eq("watch-test")
159
+ end
160
+
161
+ it { @product.tax.should be_an Float }
162
+ it { @product.created_at.should be_a String }
163
+ it { @product.shipping.should be_an Array }
164
+ it { @product.status.should be_a String }
165
+ it { @product.artists.should be_an Array }
166
+ it { @product.categories.should be_an Array }
167
+ it { @product.position.should be_an Integer }
168
+ it { @product.images.should be_an Array }
169
+ it { @product.images.first.thumb.should be_a String }
170
+ it { @product.images.first.medium.should be_a String }
171
+ it { @product.images.first.large.should be_a String }
172
+
173
+ it { @product.on_sale.should eq(!!@product.on_sale) } #Boolean test
174
+ it { @product.description.should be_a String }
175
+ it { @product.price.should be_an Float }
176
+ it { @product.name.should be_a String }
177
+ it { @product.url.should be_a String }
178
+ it { @product.default_price.should be_a Float }
179
+ it { @product.id.should be_an Integer }
180
+ it { @product.options.should be_an Array }
181
+
182
+ end
183
+
184
+ end
185
+
186
+ ##################
187
+ describe ".page" do
188
+ before do
189
+ @client = BigCartel::Client.new
190
+ end
191
+
192
+ it "will make http api calls" do
193
+ page = @client.page("park", "about")
194
+ a_request(:get, "api.bigcartel.com/park/page/about.js").
195
+ should have_been_made
196
+
197
+ a_request(:get, "api.bigcartel.com/park/store.js").
198
+ should_not have_been_made
199
+
200
+ a_request(:get, "api.bigcartel.com/park/products.js?limit=100").
201
+ should_not have_been_made
202
+ end
203
+
204
+ describe 'should build hash' do
205
+ before(:each) { @page = @client.page("park", "about")}
206
+
207
+ it "should have a permalink" do
208
+ @page.permalink.should be_a String
209
+ @page.permalink.should eq("about")
210
+ end
211
+
212
+ it { @page.content.should be_a String }
213
+ it { @page.category.should be_a String }
214
+ it { @page.name.should be_a String }
215
+ it { @page.url.should be_a String }
216
+ it { @page.id.should be_an Integer }
217
+ end
218
+
219
+ end
220
+
221
+
222
+
223
+
224
+
225
+ end