flickrie 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/flickrie.gemspec +1 -1
  2. data/lib/flickrie/version.rb +1 -1
  3. metadata +22 -150
  4. data/.gitignore +0 -10
  5. data/.travis.yml +0 -4
  6. data/.yardopts +0 -11
  7. data/CHANGELOG.md +0 -139
  8. data/Gemfile +0 -9
  9. data/Rakefile +0 -60
  10. data/spec/custom_matchers.rb +0 -51
  11. data/spec/files/photo.bla +0 -0
  12. data/spec/files/photo.jpg +0 -0
  13. data/spec/files/video.mov +0 -0
  14. data/spec/flickrie/api_methods_spec.rb +0 -124
  15. data/spec/flickrie/error_spec.rb +0 -26
  16. data/spec/flickrie/instance_spec.rb +0 -17
  17. data/spec/flickrie/license_spec.rb +0 -15
  18. data/spec/flickrie/location_spec.rb +0 -24
  19. data/spec/flickrie/media_count_spec.rb +0 -22
  20. data/spec/flickrie/media_spec.rb +0 -292
  21. data/spec/flickrie/oauth_spec.rb +0 -25
  22. data/spec/flickrie/photo_spec.rb +0 -132
  23. data/spec/flickrie/set_spec.rb +0 -76
  24. data/spec/flickrie/upload_client_spec.rb +0 -43
  25. data/spec/flickrie/user_spec.rb +0 -84
  26. data/spec/flickrie/video_spec.rb +0 -52
  27. data/spec/flickrie_spec.rb +0 -15
  28. data/spec/spec_helper.rb +0 -71
  29. data/spec/vcr_cassettes/api_methods/people/get_media_from_user.yml +0 -108
  30. data/spec/vcr_cassettes/api_methods/people/get_public_media_from_user.yml +0 -108
  31. data/spec/vcr_cassettes/api_methods/photos/add_and_remove_tags.yml +0 -528
  32. data/spec/vcr_cassettes/api_methods/photos/get_context.yml +0 -108
  33. data/spec/vcr_cassettes/api_methods/photos/get_counts.yml +0 -108
  34. data/spec/vcr_cassettes/api_methods/photos/get_exif.yml +0 -73
  35. data/spec/vcr_cassettes/api_methods/photos/get_favorites.yml +0 -73
  36. data/spec/vcr_cassettes/api_methods/photos/get_from_contacts.yml +0 -73
  37. data/spec/vcr_cassettes/api_methods/photos/get_info.yml +0 -108
  38. data/spec/vcr_cassettes/api_methods/photos/get_public_from_user_contacts.yml +0 -73
  39. data/spec/vcr_cassettes/api_methods/photos/get_sizes.yml +0 -73
  40. data/spec/vcr_cassettes/api_methods/photos/search.yml +0 -108
  41. data/spec/vcr_cassettes/api_methods/photosets/get_media.yml +0 -108
  42. data/spec/vcr_cassettes/api_methods/upload/replace.yml +0 -126
  43. data/spec/vcr_cassettes/api_methods/upload/upload.yml +0 -82
  44. data/spec/vcr_cassettes/api_methods/upload/upload_asynchronously.yml +0 -117
  45. data/spec/vcr_cassettes/error/a_request_was_made_and_failed/be_raised.yml +0 -84
  46. data/spec/vcr_cassettes/error/a_request_was_made_and_failed/have_code_attribute_present.yml +0 -84
  47. data/spec/vcr_cassettes/flickrie/a_new_credential_is_filled_in/reset_the_client.yml +0 -233
  48. data/spec/vcr_cassettes/instance/client_is_already_initialized/be_able_to_call_API_methods.yml +0 -152
  49. data/spec/vcr_cassettes/license/get/have_all_attributes_correctly_set.yml +0 -38
  50. data/spec/vcr_cassettes/media/from_contacts/have_all_attributes_correctly_set.yml +0 -73
  51. data/spec/vcr_cassettes/media/from_set/have_all_attributes_correctly_set.yml +0 -38
  52. data/spec/vcr_cassettes/media/from_user/have_all_attributes_correctly_set.yml +0 -38
  53. data/spec/vcr_cassettes/media/get_context/have_all_attributes_correctly_set.yml +0 -38
  54. data/spec/vcr_cassettes/media/get_exif/get_exif_correctly.yml +0 -73
  55. data/spec/vcr_cassettes/media/get_info/have_all_attributes_correctly_set.yml +0 -108
  56. data/spec/vcr_cassettes/media/public_from_user/have_all_attributes_correctly_set.yml +0 -38
  57. data/spec/vcr_cassettes/media/search/have_all_attributes_correctly_set.yml +0 -38
  58. data/spec/vcr_cassettes/media_count/get/have_correctly_set_all_attributes.yml +0 -73
  59. data/spec/vcr_cassettes/o_auth/incorrect_credentials/raise_exceptions.yml +0 -249
  60. data/spec/vcr_cassettes/photo/get_info/have_all_attributes_correctly_set.yml +0 -38
  61. data/spec/vcr_cassettes/photo/get_sizes/have_attributes_correctly_set.yml +0 -73
  62. data/spec/vcr_cassettes/photo/search/have_all_sizes_available.yml +0 -38
  63. data/spec/vcr_cassettes/set/from_user/have_all_attributes_correctly_set.yml +0 -143
  64. data/spec/vcr_cassettes/set/get_info/have_all_attributes_correctly_set.yml +0 -283
  65. data/spec/vcr_cassettes/upload_client/content_type/pass_the_content_type.yml +0 -117
  66. data/spec/vcr_cassettes/upload_client/invalid_credentials/raise_errors.yml +0 -276
  67. data/spec/vcr_cassettes/user/find_by_username_or_email/have_all_attributes_correctly_set.yml +0 -73
  68. data/spec/vcr_cassettes/user/get_info/have_all_attributes_correctly_set.yml +0 -73
  69. data/spec/vcr_cassettes/video/get_info/have_all_attributes_correctly_set.yml +0 -38
  70. data/spec/vcr_cassettes/video/get_sizes/have_all_attributes_correctly_set.yml +0 -73
@@ -1,124 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::ApiMethods do
4
- context "upload" do
5
- it "should upload", :vcr do
6
- photo_id = Flickrie.upload(PHOTO_PATH)
7
- expect { Flickrie.delete_photo(photo_id) }.to_not raise_error
8
- end
9
-
10
- it "should upload asynchronously", :vcr do
11
- ticket_id = Flickrie.upload(PHOTO_PATH, :async => 1)
12
- ticket = Flickrie.check_upload_tickets(ticket_id).first
13
- until ticket.complete?
14
- ticket = Flickrie.check_upload_tickets(ticket_id).first
15
- end
16
- expect { Flickrie.delete_photo(ticket.photo_id) }.to_not raise_error
17
- end
18
-
19
- it "should replace", :vcr do
20
- begin
21
- photo_id = Flickrie.upload(PHOTO_PATH)
22
- Flickrie.replace(PHOTO_PATH, photo_id)
23
- rescue => error
24
- error.message.should == "Not a pro account"
25
- ensure
26
- Flickrie.delete_photo(photo_id)
27
- end
28
- end
29
- end
30
-
31
- context "people" do
32
- it "should get media from user", :vcr do
33
- Flickrie.media_from_user(USER_NSID).first.id.should_not be_nil
34
- Flickrie.photos_from_user(USER_NSID).first.id.should_not be_nil
35
- Flickrie.videos_from_user(USER_NSID).first.id.should_not be_nil
36
- end
37
-
38
- it "should get public media from user", :vcr do
39
- Flickrie.public_media_from_user(USER_NSID).first.id.should_not be_nil
40
- Flickrie.public_photos_from_user(USER_NSID).first.id.should_not be_nil
41
- Flickrie.public_videos_from_user(USER_NSID).first.id.should_not be_nil
42
- end
43
- end
44
-
45
- # Here I test the media/photo/video aliases of the API methods (because I don't test them elsewhere)
46
- context "photos" do
47
- it "should add and remove tags", :vcr do
48
- %w[media photo video].each do |word|
49
- id = eval "#{word.upcase}_ID"
50
- media = Flickrie.send("get_#{word}_info", id)
51
- tags_before_change = media.tags.join(' ')
52
- Flickrie.send("add_#{word}_tags", id, "janko")
53
- media.get_info
54
- media.tags.join(' ').should eq([tags_before_change, "janko"].join(' '))
55
- tag_id = media.tags.find { |tag| tag.content == "janko" }.id
56
- Flickrie.send("remove_#{word}_tag", tag_id)
57
- media.get_info
58
- media.tags.join(' ').should eq(tags_before_change)
59
- end
60
- end
61
-
62
- it "should get from contacts", :vcr do
63
- params = {:include_self => 1, :single_photo => 1}
64
- Flickrie.media_from_contacts(params).first.id.should_not be_nil
65
- Flickrie.photos_from_contacts(params).first.id.should_not be_nil
66
- # Flickrie.videos_from_contacts(params).first.id.should_not be_nil
67
- end
68
-
69
- it "should get public from user contacts", :vcr do
70
- params = {:include_self => 1, :single_photo => 1}
71
- Flickrie.public_media_from_user_contacts(USER_NSID, params).first.id.should_not be_nil
72
- Flickrie.public_photos_from_user_contacts(USER_NSID, params).first.id.should_not be_nil
73
- # Flickrie.public_videos_from_user_contacts(USER_NSID, params).each { |object| object.should be_a_video }
74
- end
75
-
76
- it "should get context", :vcr do
77
- Flickrie.get_media_context(MEDIA_ID).count.should_not be_nil
78
- Flickrie.get_photo_context(PHOTO_ID).count.should_not be_nil
79
- Flickrie.get_photo_context(VIDEO_ID).count.should_not be_nil
80
- end
81
-
82
- it "should get counts", :vcr do
83
- dates = [DateTime.parse("19th May 2009"), DateTime.parse("19th May 2012")]
84
- Flickrie.get_media_counts(:taken_dates => dates.join(',')).first.value.should_not be_nil
85
- Flickrie.get_photos_counts(:taken_dates => dates.join(',')).first.value.should_not be_nil
86
- Flickrie.get_videos_counts(:taken_dates => dates.join(',')).first.value.should_not be_nil
87
- end
88
-
89
- it "should get exif", :vcr do
90
- Flickrie.get_photo_exif(PHOTO_ID).exif.should_not be_nil
91
- Flickrie.get_video_exif(VIDEO_ID).exif.should_not be_nil
92
- end
93
-
94
- it "should get favorites", :vcr do
95
- Flickrie.get_photo_favorites(PHOTO_ID).favorites.should_not be_nil
96
- Flickrie.get_video_favorites(PHOTO_ID).favorites.should_not be_nil
97
- end
98
-
99
- it "should get info", :vcr do
100
- Flickrie.get_media_info(MEDIA_ID).id.should_not be_nil
101
- Flickrie.get_photo_info(PHOTO_ID).id.should_not be_nil
102
- Flickrie.get_video_info(VIDEO_ID).id.should_not be_nil
103
- end
104
-
105
- it "should get sizes", :vcr do
106
- Flickrie.get_photo_sizes(PHOTO_ID).size.should_not be_nil
107
- Flickrie.get_video_sizes(VIDEO_ID).download_url.should_not be_nil
108
- end
109
-
110
- it "should search", :vcr do
111
- Flickrie.search_media(:user_id => USER_NSID).first.id.should_not be_nil
112
- Flickrie.search_photos(:user_id => USER_NSID).first.id.should_not be_nil
113
- Flickrie.search_videos(:user_id => USER_NSID).first.id.should_not be_nil
114
- end
115
- end
116
-
117
- context "photosets" do
118
- it "should get media", :vcr do
119
- Flickrie.media_from_set(SET_ID).first.id.should_not be_nil
120
- Flickrie.photos_from_set(SET_ID).first.id.should_not be_nil
121
- Flickrie.videos_from_set(SET_ID).first.id.should_not be_nil
122
- end
123
- end
124
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::Error do
4
- context "a request was made and failed" do
5
- it "should be raised", :vcr do
6
- Flickrie.api_key = nil
7
- expect { Flickrie.get_licenses }.to raise_error(described_class)
8
- expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(described_class)
9
- end
10
-
11
- it "should have #code attribute present", :vcr do
12
- Flickrie.api_key = nil
13
- begin
14
- Flickrie.get_licenses
15
- rescue => exception
16
- exception.code.should eq(100)
17
- end
18
-
19
- begin
20
- Flickrie.upload(PHOTO_PATH)
21
- rescue => exception
22
- exception.code.should eq(100)
23
- end
24
- end
25
- end
26
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::Instance do
4
- context "client is already initialized" do
5
- it "should be able to call API methods", :vcr do
6
- # this is to see if the client and upload_client were reset
7
- Flickrie.get_photo_info(PHOTO_ID)
8
- id = Flickrie.upload(PHOTO_PATH)
9
- Flickrie.delete_photo(id)
10
- Flickrie.access_token = Flickrie.access_secret = nil
11
-
12
- instance = Flickrie::Instance.new(ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET'])
13
- user = instance.test_login
14
- user.username.should eq(USER_USERNAME)
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::License do
4
- context "get" do
5
- it "should have all attributes correctly set", :vcr do
6
- licenses = Flickrie.get_licenses
7
-
8
- licenses.each do |license|
9
- ('0'..'8').should cover(license.id)
10
- license.name.should be_an_instance_of(String)
11
- license.url.should be_an_instance_of(String)
12
- end
13
- end
14
- end
15
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::Location do
4
- context "blank" do
5
- it "should have all attributes equal to nil" do
6
- location = Flickrie::Location.public_new
7
- attributes = location.methods - Object.instance_methods - [:[]]
8
- attributes.each do |attribute|
9
- location.send(attribute).should be_nil
10
- end
11
- end
12
- end
13
-
14
- context "accessing areas" do
15
- it "should have #to_s defined on them" do
16
- location = Flickrie::Location.public_new \
17
- 'neighbourhood' => {
18
- '_content' => 'A gangsta ghetto, yo'
19
- }
20
-
21
- location.neighbourhood.to_s.should eq('A gangsta ghetto, yo')
22
- end
23
- end
24
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::MediaCount do
4
- context "get" do
5
- it "should have correctly set all attributes", :vcr do
6
- dates = [DateTime.parse("1st March 2012"), DateTime.parse("5th May 2012")].map(&:to_time)
7
- [
8
- Flickrie.get_media_counts(:taken_dates => dates.join(',')).first,
9
- Flickrie.get_media_counts(:dates => dates.map(&:to_i).join(',')).first
10
- ].
11
- each do |count|
12
- count.value.should be_an_instance_of(Fixnum)
13
-
14
- count.date_range.begin.should eq(dates.first)
15
- count.from.should eq(dates.first)
16
-
17
- count.date_range.end.should eq(dates.last)
18
- count.to.should eq(dates.last)
19
- end
20
- end
21
- end
22
- end
@@ -1,292 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::Media do
4
- before(:all) do
5
- @attributes = {
6
- :id => PHOTO_ID,
7
- :secret => '25bb44852b',
8
- :server => '7049',
9
- :farm => 8,
10
- :title => 'IMG_0796',
11
- :description => 'Test',
12
- :media_status => 'ready',
13
- :path_alias => nil,
14
- :camera => 'Canon PowerShot G12',
15
- :comments_count => 1,
16
- :location => {
17
- :latitude => 45.807258,
18
- :longitude => 15.967599,
19
- :accuracy => '11',
20
- :context => 0,
21
- :neighbourhood => nil,
22
- :locality => {
23
- :name => 'Zagreb',
24
- :place_id => '00j4IylZV7scWik',
25
- :woeid => '851128'
26
- },
27
- :county => {
28
- :name => 'Zagreb',
29
- :place_id => '306dHrhQV7o6jm.ZUQ',
30
- :woeid => '15022257'
31
- },
32
- :region => {
33
- :name => 'Grad Zagreb',
34
- :place_id => 'Js1DU.pTUrpBCIKhVw',
35
- :woeid => '20070170'
36
- },
37
- :country => {
38
- :name => 'Croatia',
39
- :place_id => 'FunRCI5TUb6a6soTyw',
40
- :woeid => '23424843'
41
- },
42
- :place_id => '00j4IylZV7scWik',
43
- :woeid => '851128'
44
- },
45
- :geo_permissions => {
46
- :public? => true,
47
- :contacts? => false,
48
- :friends? => false,
49
- :family? => false
50
- },
51
- :tags => {
52
- :first => {
53
- :content => 'luka',
54
- :author => {
55
- :nsid => USER_NSID
56
- },
57
- :raw => 'luka',
58
- :machine_tag? => false
59
- }
60
- },
61
- :machine_tags => [],
62
- :license => {:id => '0'},
63
- :taken_at_granularity => 0,
64
- :owner => {
65
- :nsid => USER_NSID,
66
- :username => USER_USERNAME,
67
- :real_name => USER_USERNAME,
68
- :location => "Zagreb, Croatia",
69
- :icon_server => "5464",
70
- :icon_farm => 6
71
- },
72
-
73
- :safety_level => 0,
74
- :safe? => true,
75
- :moderate? => false,
76
- :restricted? => false,
77
-
78
- :visibility => {
79
- :public? => true,
80
- :family? => false,
81
- :friends? => false,
82
- :contacts? => nil
83
- },
84
- :favorite? => false,
85
-
86
- :has_people? => false,
87
- :notes => {
88
- :first => {
89
- :id => '72157629487842968',
90
- :author => {
91
- :nsid => USER_NSID,
92
- :username => USER_USERNAME
93
- },
94
- :coordinates => [316, 0],
95
- :width => 59,
96
- :height => 50,
97
- :content => 'Test'
98
- }
99
- }
100
- }
101
- end
102
-
103
- context "get info" do
104
- it "should have all attributes correctly set", :vcr do
105
- [
106
- Flickrie.get_media_info(PHOTO_ID),
107
- Flickrie::Photo.public_new('id' => PHOTO_ID).get_info,
108
- Flickrie::Video.public_new('id' => PHOTO_ID).get_info
109
- ].
110
- each do |media|
111
- [
112
- :id, :secret, :server, :farm, :title, :description,
113
- :comments_count, :location, :geo_permissions, :tags,
114
- :machine_tags, :license, :taken_at_granularity, :owner,
115
- :safety_level, :safe?, :moderate?, :restricted?, :visibility,
116
- :favorite?, :has_people?, :notes
117
- ].
118
- each do |attribute|
119
- media.send(attribute).should correspond_to(@attributes[attribute])
120
- end
121
-
122
- # can change, so just checking the type
123
- [
124
- :can_comment?, :can_add_meta?, :can_everyone_comment?,
125
- :can_everyone_add_meta?, :can_download?, :can_blog?,
126
- :can_print?, :can_share?
127
- ].
128
- each { |attribute| media.send(attribute).should be_a_boolean }
129
-
130
- media.views_count.should be_a_number
131
-
132
- # time
133
- [:posted_at, :uploaded_at, :updated_at, :taken_at].each do |time_attribute|
134
- media.send(time_attribute).should be_an_instance_of(Time)
135
- end
136
-
137
- # other
138
- media.url.should_not be_empty
139
- media['id'].should eq(PHOTO_ID)
140
- media.hash['id'].should eq(PHOTO_ID)
141
- end
142
- end
143
- end
144
-
145
- shared_context "common" do
146
- def test_common_attributes(media)
147
- [
148
- :id, :secret, :server, :farm, :title, :media_status,
149
- :geo_permissions, :machine_tags, :license, :taken_at_granularity
150
- ].
151
- each do |attribute|
152
- media.send(attribute).should correspond_to(@attributes[attribute])
153
- end
154
-
155
- # the incomplete ones
156
- media.location.should correspond_to(@attributes[:location].except(:locality, :county, :region, :country))
157
- media.tags.first.should correspond_to(@attributes[:tags][:first].except(:author, :raw, :machine_tag?))
158
- media.owner.should correspond_to(@attributes[:owner].except(:real_name, :location))
159
-
160
- # time
161
- [:uploaded_at, :updated_at, :taken_at].each do |time_attribute|
162
- media.send(time_attribute).should be_an_instance_of(Time)
163
- end
164
-
165
- # other
166
- media.url.should_not be_empty
167
- media.views_count.should be_a_number
168
- end
169
- end
170
-
171
- context "from set" do
172
- include_context "common"
173
-
174
- it "should have all attributes correctly set", :vcr do
175
- media = Flickrie.media_from_set(SET_ID, :extras => EXTRAS).
176
- find { |media| media.id == PHOTO_ID }
177
- test_common_attributes(media)
178
- media.primary?.should be_true
179
- end
180
- end
181
-
182
- context "from user" do
183
- include_context "common"
184
-
185
- it "should have all attributes correctly set", :vcr do
186
- media = Flickrie.media_from_user(USER_NSID, :extras => EXTRAS).
187
- find { |media| media.id == PHOTO_ID }
188
- test_common_attributes(media)
189
- media.visibility.should correspond_to(@attributes[:visibility])
190
- end
191
- end
192
-
193
- context "public from user" do
194
- include_context "common"
195
-
196
- it "should have all attributes correctly set", :vcr do
197
- media = Flickrie.public_media_from_user(USER_NSID, :extras => EXTRAS).
198
- find { |media| media.id == PHOTO_ID }
199
- test_common_attributes(media)
200
- media.visibility.should correspond_to(@attributes[:visibility])
201
- end
202
- end
203
-
204
- context "search" do
205
- include_context "common"
206
-
207
- it "should have all attributes correctly set", :vcr do
208
- media = Flickrie.search_media(:user_id => USER_NSID, :extras => EXTRAS).
209
- find { |media| media.id == PHOTO_ID }
210
- test_common_attributes(media)
211
- media.visibility.should correspond_to(@attributes[:visibility])
212
- end
213
- end
214
-
215
- context "from contacts" do
216
- it "should have all attributes correctly set", :vcr do
217
- params = {:include_self => 1, :single_photo => 1}
218
- [
219
- Flickrie.media_from_contacts(params).first,
220
- Flickrie.public_media_from_user_contacts(USER_NSID, params).first
221
- ].
222
- each do |media|
223
- attributes = {
224
- :id => '7093101501',
225
- :secret => '9337f28800',
226
- :server => '7090',
227
- :farm => 8,
228
- :owner => {
229
- :nsid => USER_NSID,
230
- :username => USER_USERNAME
231
- },
232
- :title => 'IMG_0917',
233
- :visibility => {:public? => true},
234
- :media_status => 'ready'
235
- }
236
-
237
- attributes.keys.each do |attribute|
238
- media.send(attribute).should correspond_to(attributes[attribute])
239
- end
240
- end
241
- end
242
- end
243
-
244
- context "get context" do
245
- it "should have all attributes correctly set", :vcr do
246
- context = Flickrie.get_media_context(PHOTO_ID)
247
- context.count.should eq(98)
248
-
249
- attributes = {
250
- :id => '6946978706',
251
- :secret => 'b38270bbd6',
252
- :server => '7216',
253
- :farm => 8,
254
- :title => 'IMG_0795',
255
- :license => {:id => '0'},
256
- :faved? => false
257
- }
258
- attributes.keys.each do |attribute|
259
- context.previous.send(attribute).should correspond_to(attributes[attribute])
260
- end
261
- context.previous.url.should_not be_empty
262
- end
263
- end
264
-
265
- context "get exif" do
266
- it "should get exif correctly", :vcr do
267
- [
268
- Flickrie.get_photo_exif(PHOTO_ID),
269
- Flickrie::Photo.public_new('id' => PHOTO_ID).get_exif
270
- ].
271
- each do |photo|
272
- photo.camera.should eq('Canon PowerShot G12')
273
- photo.exif.get('X-Resolution').should eq('180 dpi')
274
- photo.exif.get('X-Resolution', :data => 'clean').should eq('180 dpi')
275
- photo.exif.get('X-Resolution', :data => 'raw').should eq('180')
276
- end
277
- end
278
- end
279
-
280
- context "blank media" do
281
- it "should have all attributes equal to nil" do
282
- attributes = Flickrie::Media.instance_methods -
283
- Object.instance_methods -
284
- [:[], :get_info, :get_exif, :get_favorites]
285
-
286
- media = Flickrie::Photo.public_new
287
- attributes.each do |attribute|
288
- media.send(attribute).should be_nil
289
- end
290
- end
291
- end
292
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Flickrie::OAuth do
4
- context "incorrect credentials" do
5
- it "should raise exceptions", :vcr do
6
- Flickrie.api_key = "foo"
7
- Flickrie.shared_secret = "foo"
8
-
9
- expect { Flickrie::OAuth.get_request_token }.to raise_error(Flickrie::Error)
10
-
11
- Flickrie.api_key = ENV['FLICKR_API_KEY']
12
- expect { Flickrie::OAuth.get_request_token }.to raise_error(Flickrie::Error)
13
-
14
- Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
15
- expect { Flickrie::OAuth.get_request_token }.to_not raise_error(Flickrie::Error)
16
-
17
- request_token = Flickrie::OAuth.get_request_token
18
- request_token.authorize_url.should_not be_empty
19
- request_token.get_authorization_url.should_not be_empty
20
-
21
- expect { Flickrie::OAuth.get_access_token("foo", request_token) }.to raise_error(Flickrie::Error)
22
- expect { request_token.get_access_token("foo") }.to raise_error(Flickrie::Error)
23
- end
24
- end
25
- end
@@ -1,132 +0,0 @@
1
- require 'spec_helper'
2
-
3
- SIZES = ['Square 75', 'Thumbnail', 'Square 150', 'Small 240', 'Small 320',
4
- 'Medium 500', 'Medium 640', 'Medium 800', 'Large 1024']
5
-
6
- describe Flickrie::Photo do
7
- def test_sizes(photo)
8
- # non-bang versions
9
- [
10
- [[photo.square(75), photo.square75], ['Square 75', '75x75']],
11
- [[photo.thumbnail], ['Thumbnail', '75x100']],
12
- [[photo.square(150), photo.square150], ['Square 150', '150x150']],
13
- [[photo.small(240), photo.small240], ['Small 240', '180x240']],
14
- [[photo.small(320), photo.small320], ['Small 320', '240x320']],
15
- [[photo.medium(500), photo.medium500], ['Medium 500', '375x500']],
16
- [[photo.medium(640), photo.medium640], ['Medium 640', '480x640']],
17
- [[photo.medium(800), photo.medium800], ['Medium 800', '600x800']],
18
- [[photo.large(1024), photo.large1024], ['Large 1024', '768x1024']]
19
- ].
20
- each do |photos, expected_values|
21
- flickr_size, size = expected_values
22
- photos.each do |photo|
23
- photo.size.should eq(flickr_size)
24
- [photo.width, photo.height].join('x').should eq(size)
25
- photo.source_url.should_not be_empty
26
- end
27
- end
28
-
29
- # bang versions
30
- [
31
- [[proc { photo.square!(75) }, proc { photo.square75! }], ['Square 75', '75x75']],
32
- [[proc { photo.thumbnail! }], ['Thumbnail', '75x100']],
33
- [[proc { photo.square!(150) }, proc { photo.square150! }], ['Square 150', '150x150']],
34
- [[proc { photo.small!(240) }, proc { photo.small240! }], ['Small 240', '180x240']],
35
- [[proc { photo.small!(320) }, proc { photo.small320! }], ['Small 320', '240x320']],
36
- [[proc { photo.medium!(500) }, proc { photo.medium500! }], ['Medium 500', '375x500']],
37
- [[proc { photo.medium!(640) }, proc { photo.medium640! }], ['Medium 640', '480x640']],
38
- [[proc { photo.medium!(800) }, proc { photo.medium800! }], ['Medium 800', '600x800']],
39
- [[proc { photo.large!(1024) }, proc { photo.large1024! }], ['Large 1024', '768x1024']]
40
- ].
41
- each do |blocks, expected_values|
42
- flickr_size, size = expected_values
43
- blocks.each do |block|
44
- result_photo = block.call
45
- [result_photo, photo].each do |photo|
46
- photo.size.should eq(flickr_size)
47
- [photo.width, photo.height].join('x').should eq(size)
48
- photo.source_url.should_not be_empty
49
- end
50
- end
51
- end
52
- end
53
-
54
- context "get sizes" do
55
- it "should have attributes correctly set", :vcr do
56
- [
57
- Flickrie.get_photo_sizes(PHOTO_ID),
58
- Flickrie::Photo.public_new('id' => PHOTO_ID).get_sizes
59
- ].
60
- each do |photo|
61
- [:can_download?, :can_blog?, :can_print?].each do |attribute|
62
- photo.send(attribute).should be_a_boolean
63
- end
64
-
65
- test_sizes(photo)
66
- photo.available_sizes.should eq(SIZES)
67
- end
68
- end
69
- end
70
-
71
- context "search" do
72
- it "should have all sizes available", :vcr do
73
- photo = Flickrie.search_photos(:user_id => USER_NSID, :extras => EXTRAS).
74
- find { |photo| photo.id == PHOTO_ID }
75
- photo.available_sizes.should eq(SIZES)
76
- end
77
- end
78
-
79
- context "get info" do
80
- it "should have all attributes correctly set", :vcr do
81
- photo = Flickrie.get_photo_info(PHOTO_ID)
82
- photo.rotation.should eq(90)
83
- end
84
- end
85
-
86
- context "blank photo" do
87
- it "should have all attributes equal to nil" do
88
- photo = Flickrie::Photo.public_new
89
-
90
- photo.width.should be_nil
91
- photo.height.should be_nil
92
- photo.source_url.should be_nil
93
- photo.rotation.should be_nil
94
- photo.available_sizes.should be_empty
95
- photo.size.should be_nil
96
-
97
- [
98
- photo.square(75), photo.square(150), photo.thumbnail,
99
- photo.small(240), photo.small(320), photo.medium(500),
100
- photo.medium(640), photo.medium(800), photo.large(1024),
101
- photo.original, photo.square75, photo.square150,
102
- photo.small240, photo.small320, photo.medium500,
103
- photo.medium640, photo.medium800, photo.large1024,
104
- photo.largest
105
- ].
106
- each do |photo|
107
- photo.source_url.should be_nil
108
- photo.width.should be_nil
109
- photo.height.should be_nil
110
- end
111
-
112
- [
113
- proc { photo.square!(75) }, proc { photo.square!(150) },
114
- proc { photo.thumbnail! }, proc { photo.small!(240) },
115
- proc { photo.small!(320) }, proc { photo.medium!(500) },
116
- proc { photo.medium!(640) }, proc { photo.medium!(800) },
117
- proc { photo.large!(1024) }, proc { photo.original! },
118
- proc { photo.square75! }, proc { photo.square150! },
119
- proc { photo.small240! }, proc { photo.small320! },
120
- proc { photo.medium500! }, proc { photo.medium640! },
121
- proc { photo.medium800! }, proc { photo.large1024! },
122
- proc { photo.largest! }
123
- ].
124
- each do |prok|
125
- prok.call
126
- photo.source_url.should be_nil
127
- photo.width.should be_nil
128
- photo.height.should be_nil
129
- end
130
- end
131
- end
132
- end