flickrmocks 0.8.15 → 0.9.0

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 (53) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile.lock +123 -0
  3. data/README.rdoc +104 -30
  4. data/Rakefile +12 -0
  5. data/flickrmocks.gemspec +3 -1
  6. data/lib/flickr_mocks/api/api.rb +80 -27
  7. data/lib/flickr_mocks/api/flickr.rb +69 -23
  8. data/lib/flickr_mocks/api/helpers.rb +25 -12
  9. data/lib/flickr_mocks/api/options.rb +71 -53
  10. data/lib/flickr_mocks/api/sanitize.rb +129 -20
  11. data/lib/flickr_mocks/fixtures.rb +7 -1
  12. data/lib/flickr_mocks/flickraw/custom_clone.rb +3 -1
  13. data/lib/flickr_mocks/flickraw/custom_compare.rb +4 -0
  14. data/lib/flickr_mocks/flickraw/custom_marshal.rb +7 -2
  15. data/lib/flickr_mocks/flickraw/flickraw.rb +6 -0
  16. data/lib/flickr_mocks/helpers.rb +8 -1
  17. data/lib/flickr_mocks/models/commons_institution.rb +45 -34
  18. data/lib/flickr_mocks/models/commons_institutions.rb +85 -75
  19. data/lib/flickr_mocks/models/helpers.rb +13 -6
  20. data/lib/flickr_mocks/models/models.rb +7 -0
  21. data/lib/flickr_mocks/models/photo.rb +76 -75
  22. data/lib/flickr_mocks/models/photo_details.rb +71 -69
  23. data/lib/flickr_mocks/models/photo_dimensions.rb +80 -78
  24. data/lib/flickr_mocks/models/photo_search.rb +115 -88
  25. data/lib/flickr_mocks/models/photo_size.rb +57 -56
  26. data/lib/flickr_mocks/models/photo_sizes.rb +68 -67
  27. data/lib/flickr_mocks/models/photos.rb +104 -99
  28. data/lib/flickr_mocks/stubs.rb +151 -14
  29. data/lib/flickr_mocks/version.rb +7 -1
  30. data/spec/api/api_spec.rb +26 -8
  31. data/spec/api/flickr_spec.rb +19 -19
  32. data/spec/api/helper_spec.rb +20 -20
  33. data/spec/api/options_spec.rb +170 -124
  34. data/spec/api/sanitize_spec.rb +174 -59
  35. data/spec/base/stubs_spec.rb +37 -74
  36. data/spec/base/version_spec.rb +11 -4
  37. data/spec/models/commons_institution_spec.rb +3 -2
  38. data/spec/models/commons_institutions_spec.rb +34 -5
  39. data/spec/models/helpers_spec.rb +7 -6
  40. data/spec/models/photo_details_spec.rb +12 -11
  41. data/spec/models/photo_dimensions_spec.rb +5 -4
  42. data/spec/models/photo_search_spec.rb +50 -8
  43. data/spec/models/photo_size_spec.rb +4 -3
  44. data/spec/models/photo_sizes_spec.rb +6 -5
  45. data/spec/models/photo_spec.rb +6 -4
  46. data/spec/models/photos_spec.rb +9 -7
  47. data/spec/shared_examples/hash_options/date_hash_option.rb +42 -0
  48. data/spec/shared_examples/hash_options/page_hash_option.rb +23 -0
  49. data/spec/shared_examples/hash_options/perpage_hash_option.rb +43 -0
  50. data/spec/shared_examples/hash_options/tag_mode_hash_option.rb +31 -0
  51. data/spec/shared_examples/stub_helpers.rb +140 -0
  52. data/spec/spec_helper.rb +5 -5
  53. metadata +55 -16
@@ -1,90 +1,205 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::Api do
4
- let(:klass) {APP::Api}
5
-
3
+ describe APP::Api::Sanitize do
4
+ let(:klass) {APP::Api::Sanitize}
5
+ let(:api){APP::Api}
6
6
 
7
7
  context "class methods" do
8
- specify {klass.should respond_to(:sanitize_tags)}
9
- context "sanitize_tags" do
10
- it "returns expected tags when specified" do
11
- klass.sanitize_tags('iran,shiraz').should == 'iran,shiraz'
12
- end
13
- it "returns lower cased version of tags when mixed case tag is specified" do
14
- klass.sanitize_tags('IrAn,ShiRaZ').should == 'iran,shiraz'
15
- end
16
- it "returns tags stripped of extraneous spaces between tags" do
17
- klass.sanitize_tags('iran , shiraz ').should == 'iran,shiraz'
18
- end
19
- it "returns tags that preserve spaces within a tag" do
20
- klass.sanitize_tags('iran , shiraz hafez, isfehan').should == 'iran,shiraz hafez,isfehan'
8
+ specify {klass.should respond_to(:tags)}
9
+ context "tags" do
10
+ it "returns nil when nil supplied" do
11
+ klass.tags(nil).should == nil
12
+ end
13
+ context "specified as a string" do
14
+ it "returns expected tags when specified" do
15
+ klass.tags('iran,shiraz').should == 'iran,shiraz'
16
+ end
17
+ it "returns lower cased version of tags when mixed case tag is specified" do
18
+ klass.tags('IrAn,ShiRaZ').should == 'iran,shiraz'
19
+ end
20
+ it "returns tags stripped of extraneous spaces between tags" do
21
+ klass.tags('iran , shiraz ').should == 'iran,shiraz'
22
+ end
23
+ it "returns tags that preserve spaces within a tag" do
24
+ klass.tags('iran , shiraz hafez, isfehan').should == 'iran,shiraz hafez,isfehan'
25
+ end
26
+ end
27
+ context "error conditions" do
28
+ it "raises error when Array supplied" do
29
+ expect {
30
+ klass.tags([])
31
+ }.to raise_error(ArgumentError)
32
+ end
33
+ it "raises error when Integer supplied" do
34
+ expect {
35
+ klass.tags(1)
36
+ }.to raise_error(ArgumentError)
37
+ end
21
38
  end
22
39
  end
23
-
24
- specify {klass.should respond_to(:sanitize_per_page)}
25
- context "sanitize_per_page" do
26
- it "returns expected per_page when per_page specified" do
27
- klass.sanitize_per_page(:per_page => '2').should == '2'
40
+
41
+ specify {klass.should respond_to(:tags_hash)}
42
+ context ":tags_hash" do
43
+ it "returns tags when :search_terms supplied" do
44
+ klass.tags_hash(:search_terms => "lyon,france").should ==
45
+ "lyon,france"
28
46
  end
29
- it "returns default per_page when per_page is not specified" do
30
- klass.sanitize_per_page({}).should == klass.default(:per_page)
47
+ it "returns nil when :search_terms is nil supplied" do
48
+ klass.tags_hash(:search_terms => nil).should be_nil
31
49
  end
32
- it "returns expected per_page when perpage specified" do
33
- klass.sanitize_per_page(:perpage => '33').should == '33'
50
+ it "returns nil when :search_terms not supplied" do
51
+ klass.tags_hash({}).should be_nil
34
52
  end
35
- it "returns per_page when both :perpage and per_page is specified" do
36
- klass.sanitize_per_page(:per_page => '222', :perpage => '333').should == '222'
53
+ it "raises argument error when Array supplied" do
54
+ expect {
55
+ klass.tags_hash([])
56
+ }.to raise_error(ArgumentError)
37
57
  end
38
58
  end
39
59
 
40
- specify {klass.should respond_to(:sanitize_page)}
41
- context "sanitize_page" do
42
- it "returns specified page number when given" do
43
- klass.sanitize_page(:page => 2).should == '2'
44
- end
45
- it "returns '1' when page number not specified" do
46
- klass.sanitize_page({}).should == '1'
47
- end
48
- it "returns '1' when string '0' specified for page number" do
49
- klass.sanitize_page(:page => '0').should == '1'
50
- end
51
- it "returns '1' when number 0 specified as page number" do
52
- klass.sanitize_page(:page => 0).should == '1'
60
+ specify {klass.should respond_to(:per_page)}
61
+ context "per_page" do
62
+ it "returns default per_page when nil provided" do
63
+ klass.per_page(nil).should == api.default(:per_page)
64
+ end
65
+ context "option as string" do
66
+ it "returns value when string containing integer greater than 0" do
67
+ klass.per_page('2').should == '2'
68
+ end
69
+ it "returns default per_page value when string is less than 1" do
70
+ klass.per_page('-1').should == FlickrMocks::Api.default(:per_page)
71
+ end
72
+ it "returns default per_page value when string is '0'" do
73
+ klass.per_page('0').should == FlickrMocks::Api.default(:per_page)
74
+ end
75
+ end
76
+ context "option as integer" do
77
+ it "returns value.to_s when option is greater than 0" do
78
+ klass.per_page(2).should == '2'
79
+ end
80
+ it "returns default :per_page when option is 0" do
81
+ klass.per_page(0).should == FlickrMocks::Api.default(:per_page)
82
+ end
83
+ it "returns default :per_page when option is negative" do
84
+ klass.per_page(-1).should == FlickrMocks::Api.default(:per_page)
85
+ end
86
+ end
87
+ context "error conditions" do
88
+ it "raises an error when an array provided" do
89
+ expect {
90
+ klass.per_page([])
91
+ }.to raise_error(ArgumentError)
92
+ end
53
93
  end
54
94
  end
55
95
 
56
- specify {klass.should respond_to(:sanitize_tag_mode)}
57
- context "sanitize_tag_mode" do
58
- it "returns 'any' if specified" do
59
- klass.sanitize_tag_mode(:tag_mode => 'any').should == 'any'
60
- end
61
- it "returns default tag_mode when non-specified" do
62
- klass.sanitize_tag_mode.should == klass.default(:tag_mode)
63
- end
64
- it "returns default tag_mode when garbage specified" do
65
- klass.sanitize_tag_mode(:tag_mode => 'garbage').should == klass.default(:tag_mode)
96
+ specify {klass.should respond_to(:per_page_hash)}
97
+ context ":per_page_hash" do
98
+ let(:options){{}}
99
+ let(:method){:per_page_hash}
100
+ it_behaves_like "per page hash option"
101
+ end
102
+
103
+ # returns the page entry that is a positive non-zero integer
104
+ specify {klass.should respond_to(:page)}
105
+ context "page" do
106
+ it "returns '1' when page number is nil" do
107
+ klass.page(nil).should == '1'
108
+ end
109
+ context "integer argument" do
110
+ it "returns default page when number is 0" do
111
+ klass.page(0).should == FlickrMocks::Api.default(:page)
112
+ end
113
+ it "returns default page when number < 0" do
114
+ klass.page(-1).should == FlickrMocks::Api.default(:page)
115
+ end
116
+ it "returns page when number > 0" do
117
+ klass.page(20).should == '20'
118
+ end
119
+ end
120
+ context "string argument" do
121
+ it "returns specified page number when given" do
122
+ klass.page(2).should == '2'
123
+ end
124
+ it "returns '1' when string '0' specified for page number" do
125
+ klass.page('0').should == FlickrMocks::Api.default(:page)
126
+ end
127
+ it "returns '1' when number 0 specified as page number" do
128
+ klass.page(0).should == FlickrMocks::Api.default(:page)
129
+ end
130
+ end
131
+ context "error conditions" do
132
+ it "raises error when Array specified" do
133
+ expect {
134
+ klass.page([])
135
+ }.to raise_error(ArgumentError)
136
+ end
66
137
  end
138
+ end
139
+ specify {klass.should respond_to(:page_hash)}
140
+ context ":page_hash" do
141
+ let(:options){{}}
142
+ let(:method){:page_hash}
143
+ it_behaves_like "page hash option"
144
+ end
145
+
146
+ specify {klass.should respond_to(:tag_mode)}
147
+ context "tag_mode" do
67
148
  it "returns default tag mode if nil given" do
68
- klass.sanitize_tag_mode(:tag_mode => nil).should == klass.default(:tag_mode)
69
- end
70
- it "returns 'all' if specified" do
71
- klass.sanitize_tag_mode(:tag_mode => 'all').should == 'all'
149
+ klass.tag_mode(nil).should == api.default(:tag_mode)
150
+ end
151
+ context "options specified as string" do
152
+ it "returns 'any' if specified" do
153
+ klass.tag_mode('any').should == 'any'
154
+ end
155
+ it "returns default tag_mode when non-specified" do
156
+ klass.tag_mode.should == api.default(:tag_mode)
157
+ end
158
+ it "returns default tag_mode when garbage specified" do
159
+ klass.tag_mode('garbage').should == api.default(:tag_mode)
160
+ end
161
+ it "returns 'all' if specified" do
162
+ klass.tag_mode('all').should == 'all'
163
+ end
164
+ end
165
+ context "error conditions" do
166
+ it "raises error when array provided" do
167
+ expect {
168
+ klass.tag_mode([])
169
+ }.to raise_error(ArgumentError)
170
+
171
+ end
72
172
  end
73
173
  end
74
174
 
75
- specify {klass.should respond_to(:sanitize_time)}
76
- context "sanitize_time" do
175
+ specify {klass.should respond_to(:tag_mode_hash)}
176
+ context ":tag_mode_hash" do
177
+ let(:options){{}}
178
+ let(:method){:tag_mode_hash}
179
+ it_behaves_like "tag mode hash option"
180
+ end
181
+
182
+ specify {klass.should respond_to(:date)}
183
+ context "date" do
77
184
  it "returns expected date when format '2010-12-22'" do
78
- klass.sanitize_time(:date => '2010-12-22').should == '2010-12-22'
185
+ klass.date('2010-12-22').should == '2010-12-22'
79
186
  end
80
187
  it "returns expected date when format 'Jan 1 2003'" do
81
188
  date = Chronic.parse('Jan 1 2003').strftime('%Y-%m-%d')
82
- klass.sanitize_time(:date => 'Jan 1 2003').should == date
189
+ klass.date('Jan 1 2003').should == date
83
190
  end
84
191
  it "returns yesterday if no date specified" do
85
192
  date = Chronic.parse('yesterday').strftime('%Y-%m-%d')
86
- klass.sanitize_time.should == date
193
+ klass.date.should == date
87
194
  end
88
195
  end
196
+
197
+ specify {klass.should respond_to(:date_hash)}
198
+ context ":date_hash" do
199
+ let(:options){{}}
200
+ let(:method){:date_hash}
201
+ it_behaves_like "date hash option"
202
+ end
203
+
89
204
  end
90
205
  end
@@ -6,9 +6,10 @@ describe APP::Stubs do
6
6
  let(:flickr_stubs){klass::Flickr}
7
7
  let(:api_stubs){klass::Api}
8
8
  let(:api){APP::Api}
9
+ let(:models){APP::Models}
10
+
9
11
  context "class methods" do
10
- context "Flickr Stubs" do
11
-
12
+ context "Flickr" do
12
13
  specify{flickr_stubs.should respond_to(:all)}
13
14
  context "all" do
14
15
  before(:each) do
@@ -192,7 +193,7 @@ describe APP::Stubs do
192
193
  /Not a valid date string/
193
194
  )
194
195
  end
195
- it "returns empty string if 2001-01-01 given" do
196
+ it "returns empty string if 2000-01-01 given" do
196
197
  flickr.interestingness.getList(:date => '2000-01-01').should == fixtures.empty_photos
197
198
  end
198
199
  it "returns photo details fixture when option given" do
@@ -211,47 +212,26 @@ describe APP::Stubs do
211
212
  end
212
213
  end
213
214
 
214
- context "Api stubs" do
215
+ context "Api" do
216
+ specify{api_stubs.should respond_to(:all)}
217
+ context "all" do
218
+ before(:each) do
219
+ api_stubs.all
220
+ end
221
+ it_behaves_like "stub for Api.photo"
222
+ it_behaves_like "stub for Api.photos"
223
+ it_behaves_like "stub for Api.photo_details"
224
+ it_behaves_like "stub for Api.photo_sizes"
225
+ it_behaves_like "stub for Api.interesting_photos"
226
+ it_behaves_like "stub for Api.commons_institutions"
227
+ end
228
+
215
229
  specify {api_stubs.should respond_to :photos}
216
230
  context "photos" do
217
231
  before(:each) do
218
232
  api_stubs.photos
219
233
  end
220
- context "owner_id provided" do
221
- it "returns object with same user when owner_id provided" do
222
- params = {:owner_id => '1'}
223
- api.photos(:owner_id => '1').should ==
224
- ::FlickrMocks::PhotoSearch.new(fixtures.photos,api.search_params(params))
225
- end
226
- it "returns object with same user when owner_id and tags provided" do
227
- params = {:owner_id => '1',:search_terms => 'iran'}
228
- api.photos(:owner_id => '1').should ==
229
- ::FlickrMocks::PhotoSearch.new(fixtures.photos,api.search_params({:owner_id => '1'}))
230
- end
231
- it "returns object with no entries when owner_id set to 'garbage'" do
232
- api.photos(:owner_id => 'garbage').should ==
233
- ::FlickrMocks::PhotoSearch.new(fixtures.empty_photos,api.search_params({:owner_id => 'garbage'}))
234
- end
235
- end
236
- context "search_terms provided" do
237
- it "returns object with different owner_id values when :search_terms provided" do
238
- params = {:search_terms => 'iran'}
239
- api.photos(params).should ==
240
- ::FlickrMocks::PhotoSearch.new(fixtures.photos,api.search_params(params))
241
- end
242
- it "returns object with no entries when :search_terms is set to 'garbage'" do
243
- params = {:search_terms => 'garbage'}
244
- api.photos(params).should ==
245
- ::FlickrMocks::PhotoSearch.new(fixtures.empty_photos,api.search_params(params))
246
- end
247
- end
248
-
249
- context "error conditions" do
250
- let(:subject){api}
251
- let(:method){:photos}
252
- it_behaves_like "object that expects single Hash argument"
253
- end
254
-
234
+ it_behaves_like "stub for Api.photos"
255
235
  end
256
236
 
257
237
  specify {api_stubs.should respond_to :photo_details}
@@ -259,58 +239,41 @@ describe APP::Stubs do
259
239
  before(:each) do
260
240
  api_stubs.photo_details
261
241
  end
262
- it "returns expected object when proper :photo_id provided" do
263
- api.photo_details(:photo_id => '1234').should ==
264
- ::FlickrMocks::PhotoDetails.new(fixtures.photo_details,fixtures.photo_sizes)
265
- end
266
-
267
- context "error conditions" do
268
- let(:subject){api}
269
- let(:method){:photo_details}
270
- it_behaves_like "object that expects single Hash argument"
271
-
272
- it "raises FlickRaw::FailedResponse when :photo_id not supplied in Hash" do
273
- expect {
274
- api.photo_details({})
275
- }.to raise_error(FlickRaw::FailedResponse)
276
- end
277
- it "raises FlickRaw::FailedResponse when :photo_id is nil" do
278
- expect {
279
- api.photo_details({:photo_id => nil})
280
- }.to raise_error(FlickRaw::FailedResponse)
281
- end
282
- it "raises FlickRaw::FailedResponse when :photo_id is garbage" do
283
- expect {
284
- api.photo_details({:photo_id => 'garbage'})
285
- }.to raise_error(FlickRaw::FailedResponse)
286
- end
287
- end
242
+ it_behaves_like "stub for Api.photo_details"
288
243
  end
289
244
 
290
245
  specify {api_stubs.should respond_to :photo}
291
246
  context "photo" do
292
- context "error conditions" do
247
+ before(:each) do
248
+ api_stubs.photo
293
249
  end
294
-
250
+ it_behaves_like "stub for Api.photo"
295
251
  end
296
252
 
297
253
  specify {api_stubs.should respond_to :photo_sizes}
298
254
  context "photo_sizes" do
299
-
255
+ before(:each) do
256
+ api_stubs.photo_sizes
257
+ end
258
+ it_behaves_like "stub for Api.photo_sizes"
300
259
  end
301
260
 
302
261
  specify {api_stubs.should respond_to :interesting_photos}
303
262
  context "interesting_photos" do
304
-
263
+ before(:each) do
264
+ api_stubs.interesting_photos
265
+ end
266
+ it_behaves_like "stub for Api.interesting_photos"
305
267
  end
306
268
 
307
269
  specify {api_stubs.should respond_to :commons_institutions}
308
270
  context "commons_institutions" do
309
-
271
+ before(:each) do
272
+ api_stubs.commons_institutions
273
+ end
274
+ it_behaves_like "stub for Api.commons_institutions"
310
275
  end
311
-
312
- end
313
-
314
-
276
+ end
315
277
  end
278
+
316
279
  end
@@ -1,12 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::VERSION do
4
- subject{APP::VERSION}
5
-
3
+ describe APP do
4
+ subject{APP}
6
5
  context "constants" do
7
6
  context "VERSION" do
8
7
  it "returns non-empty version" do
9
- subject.should_not be_empty
8
+ subject::VERSION.should_not be_empty
9
+ end
10
+ end
11
+ end
12
+
13
+ context "class methods" do
14
+ context "version" do
15
+ it "returns expected version" do
16
+ subject.version.should == subject::VERSION
10
17
  end
11
18
  end
12
19
  end
@@ -1,8 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::CommonsInstitution do
3
+ describe APP::Models::CommonsInstitution do
4
4
  let(:api) {APP::Api}
5
- let(:klass) {APP::CommonsInstitution}
5
+ let(:models){APP::Models}
6
+ let(:klass) {models::CommonsInstitution}
6
7
  let(:fixtures){APP::Fixtures.instance}
7
8
  let(:fixture){fixtures.commons_institutions[0]}
8
9
  subject {klass.new(fixture)}
@@ -1,8 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::CommonsInstitutions do
3
+ describe APP::Models::CommonsInstitutions do
4
4
  let(:api) {APP::Api}
5
- let(:klass) {APP::CommonsInstitutions}
5
+ let(:models){APP::Models}
6
+ let(:klass) {models::CommonsInstitutions}
6
7
  let(:fixtures){APP::Fixtures.instance}
7
8
  let(:fixture){fixtures.commons_institutions}
8
9
  subject {klass.new(fixture)}
@@ -11,7 +12,7 @@ describe APP::CommonsInstitutions do
11
12
  context "class methods" do
12
13
  specify { klass.should respond_to(:defaults)}
13
14
  it "returns expected set of defaults" do
14
- klass.defaults.should == FlickrMocks::Models::Helpers.paging_defaults
15
+ klass.defaults.should == models::Helpers.paging_defaults
15
16
  end
16
17
  end
17
18
 
@@ -28,6 +29,34 @@ describe APP::CommonsInstitutions do
28
29
  end
29
30
 
30
31
  context "instance methods" do
32
+ specify {subject.should respond_to(:extract_per_page)}
33
+ context "#extract_per_page" do
34
+ let(:method){:extract_per_page}
35
+ let(:options){{}}
36
+ it_behaves_like "per page hash option"
37
+ end
38
+
39
+ specify {subject.should respond_to(:extract_current_page)}
40
+ context "#extract_current_page" do
41
+ let(:method){:extract_current_page}
42
+ context ":page option provided" do
43
+ let(:options){{}}
44
+ it_behaves_like "page hash option"
45
+ end
46
+ context ":current_page option" do
47
+ it "returns page number when current_page given" do
48
+ subject.extract_current_page(:current_page => '2').should == '2'
49
+ end
50
+ it "prefers :current_page to :page" do
51
+ subject.extract_current_page(:current_page => '3', :page => '30').should == '3'
52
+ end
53
+ it "returns default page when :current_page is set to nil" do
54
+ subject.extract_current_page(:current_page => nil).should == FlickrMocks::Api.default(:page)
55
+ end
56
+ end
57
+ end
58
+
59
+
31
60
  specify {subject.should respond_to(:default)}
32
61
  context "#default" do
33
62
  it "should return default when proper symbol provided" do
@@ -71,14 +100,14 @@ describe APP::CommonsInstitutions do
71
100
  context "#per_page" do
72
101
  it "returns default per_page when none specified at initialization" do
73
102
  klass.new(fixture,:current_page => 1).per_page.should ==
74
- FlickrMocks::Models::Helpers.paging_defaults[:per_page]
103
+ api.default(:per_page).to_i
75
104
  end
76
105
  it "returns per_page value that was specified during initialization" do
77
106
  klass.new(fixture,:per_page => 33, :current_page => 1).per_page.should == 33
78
107
  end
79
108
  it "returns 1 when per_page is set to 0" do
80
109
  klass.new(fixture,:per_page => 0, :current_page => 1).per_page.should ==
81
- FlickrMocks::Models::Helpers.paging_defaults[:per_page]
110
+ api.default(:per_page).to_i
82
111
  end
83
112
  end
84
113
 
@@ -21,17 +21,18 @@ describe APP::Models::Helpers do
21
21
  :medium_640, :large, :original]
22
22
  end
23
23
  end
24
-
24
+
25
25
  specify {klass.should respond_to(:paging_defaults)}
26
26
  context "paging_defaults" do
27
- it "returns expected hash of paging defaults" do
27
+ it "returns expected hash containing paging defaults" do
28
28
  klass.paging_defaults.should == {
29
- :max_entries => 4000,
30
- :per_page => 50,
31
- :current_page => 1
29
+ :max_entries => ::FlickrMocks::Api.default(:max_entries).to_i,
30
+ :per_page => ::FlickrMocks::Api.default(:per_page).to_i,
31
+ :current_page => ::FlickrMocks::Api.default(:page).to_i
32
32
  }
33
33
  end
34
34
  end
35
-
35
+
36
36
  end
37
37
  end
38
+
@@ -1,12 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::PhotoDetails do
4
- let(:klass){APP::PhotoDetails}
3
+ describe APP::Models::PhotoDetails do
4
+ let(:klass){APP::Models::PhotoDetails}
5
5
  let(:fixtures){APP::Fixtures.instance}
6
+ let(:models){APP::Models}
6
7
 
7
- let(:basic_photo) { APP::Photo.new fixtures.photo }
8
- let(:extended_photo) { APP::Photo.new fixtures.photo_details }
9
- let(:photo_sizes) { APP::PhotoSizes.new fixtures.photo_sizes }
8
+ let(:basic_photo) { models::Photo.new fixtures.photo }
9
+ let(:extended_photo) { models::Photo.new fixtures.photo_details }
10
+ let(:photo_sizes) { models::PhotoSizes.new fixtures.photo_sizes }
10
11
 
11
12
  let(:photo_details_basic){klass.new(basic_photo,photo_sizes)}
12
13
  let(:photo_details_extended){klass.new(extended_photo,photo_sizes)}
@@ -23,16 +24,16 @@ describe APP::PhotoDetails do
23
24
  klass.new(fixtures.photo_details,fixtures.photo_sizes).should be_a(klass)
24
25
  end
25
26
  it "raises an error when Array supplied for photo" do
26
- lambda{APP::PhotoDetails.new [],photo_sizes}.should raise_error ArgumentError
27
+ lambda{models::PhotoDetails.new [],photo_sizes}.should raise_error ArgumentError
27
28
  end
28
29
  it "raises an error when Array supplied for photo_details" do
29
- lambda{APP::PhotoDetails.new extended_photo,[]}.should raise_error ArgumentError
30
+ lambda{models::PhotoDetails.new extended_photo,[]}.should raise_error ArgumentError
30
31
  end
31
32
  it "raises error when nil supplied for photo_sizes" do
32
- lambda{APP::PhotoDetails.new extended_photo,nil}.should raise_error ArgumentError
33
+ lambda{models::PhotoDetails.new extended_photo,nil}.should raise_error ArgumentError
33
34
  end
34
35
  it "raises error when nil supplied for photo_details" do
35
- lambda{APP::PhotoDetails.new nil,photo_sizes}.should raise_error ArgumentError
36
+ lambda{models::PhotoDetails.new nil,photo_sizes}.should raise_error ArgumentError
36
37
  end
37
38
  end
38
39
 
@@ -118,7 +119,7 @@ describe APP::PhotoDetails do
118
119
  end
119
120
  end
120
121
  it "returns expected result delegated to url helpers for basic photo" do
121
- reference = APP::Photo.new(fixtures.photo)
122
+ reference = models::Photo.new(fixtures.photo)
122
123
  FlickrMocks::Models::Helpers.possible_sizes.each do |size|
123
124
  subject.send(size).should == reference.send(size)
124
125
  end
@@ -133,7 +134,7 @@ describe APP::PhotoDetails do
133
134
  end
134
135
  end
135
136
  it "returns expected result delegated to url helpers for detailed photo" do
136
- reference = APP::Photo.new(fixtures.photo_details)
137
+ reference = models::Photo.new(fixtures.photo_details)
137
138
  FlickrMocks::Models::Helpers.possible_sizes.each do |size|
138
139
  subject.send(size).should == reference.send(size)
139
140
  end
@@ -1,11 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe APP::PhotoDimensions do
3
+ describe APP::Models::PhotoDimensions do
4
4
  let(:dimensions_string) {'square:1x11,thumbnail:2x12,small:3x13,medium:4x14,medium_640:5x15,large:6x16,original:7x17'}
5
5
  let(:expected_sizes) { [:square, :thumbnail, :small, :medium,:medium_640, :large, :original] }
6
- let(:klass) {APP::PhotoDimensions}
6
+ let(:models){APP::Models}
7
+ let(:klass) {models::PhotoDimensions}
7
8
 
8
- subject { APP::PhotoDimensions.new(dimensions_string) }
9
+ subject { models::PhotoDimensions.new(dimensions_string) }
9
10
 
10
11
  context "class methods" do
11
12
  specify {klass.should respond_to(:regexp_size)}
@@ -148,7 +149,7 @@ describe APP::PhotoDimensions do
148
149
  end
149
150
 
150
151
  context "partially specified dimensions" do
151
- subject {APP::PhotoDimensions.new('square:1x11')}
152
+ subject {models::PhotoDimensions.new('square:1x11')}
152
153
  it "should return object for dimensions that are specified" do
153
154
  subject.send(:square).should_not be_nil
154
155
  end