flickrie 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,30 +8,30 @@ http_interactions:
8
8
  string: ""
9
9
  headers:
10
10
  Authorization:
11
- - OAuth oauth_consumer_key="foo", oauth_nonce="f0b516bcf18b7ce5361015b2f3e16825", oauth_signature="3yBzvaPpjWcvd9MYwfFycmDwL4w%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337013923", oauth_version="1.0"
11
+ - OAuth oauth_consumer_key="foo", oauth_nonce="343828b763700300dc63df28dee85a7c", oauth_signature="qv48Khp9bvT4WvEhHMMbtSFCnQE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337106972", oauth_version="1.0"
12
12
  response:
13
13
  status:
14
14
  code: 401
15
15
  message:
16
16
  headers:
17
17
  date:
18
- - Mon, 14 May 2012 16:45:23 GMT
18
+ - Tue, 15 May 2012 18:36:13 GMT
19
19
  p3p:
20
20
  - policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
21
21
  set-cookie:
22
- - localization=en-us%3Bus%3Bus; expires=Mon, 12-May-2014 16:45:23 GMT; path=/; domain=.flickr.com
22
+ - localization=en-us%3Bus%3Bus; expires=Tue, 13-May-2014 18:36:13 GMT; path=/; domain=.flickr.com
23
23
  cache-control:
24
24
  - private
25
25
  x-served-by:
26
- - www148.flickr.mud.yahoo.com
26
+ - www150.flickr.mud.yahoo.com
27
27
  vary:
28
28
  - Accept-Encoding
29
29
  content-type:
30
30
  - text/plain;charset=UTF-8
31
31
  age:
32
- - "2"
32
+ - "0"
33
33
  via:
34
- - HTTP/1.1 r17.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r11.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
34
+ - HTTP/1.1 r39.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r12.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
35
35
  server:
36
36
  - YTS/1.20.16
37
37
  connection:
@@ -40,7 +40,7 @@ http_interactions:
40
40
  encoding: ASCII-8BIT
41
41
  string: oauth_problem=consumer_key_unknown
42
42
  http_version:
43
- recorded_at: Mon, 14 May 2012 16:45:24 GMT
43
+ recorded_at: Tue, 15 May 2012 18:36:13 GMT
44
44
  - request:
45
45
  method: get
46
46
  uri: http://www.flickr.com/services/oauth/request_token?oauth_callback=oob
@@ -49,22 +49,22 @@ http_interactions:
49
49
  string: ""
50
50
  headers:
51
51
  Authorization:
52
- - OAuth oauth_consumer_key="API_KEY", oauth_nonce="fd7c73dbb8eeabcc3a3827ff05e3620c", oauth_signature="wfkELOLgWkl0DRjZVdLbg39OabQ%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337013924", oauth_version="1.0"
52
+ - OAuth oauth_consumer_key="API_KEY", oauth_nonce="74d7fa04db335e2937437ae76ee1f0d7", oauth_signature="FLbia4X%2FI%2B2YNi2JOImB1aUzCiU%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337106973", oauth_version="1.0"
53
53
  response:
54
54
  status:
55
55
  code: 401
56
56
  message:
57
57
  headers:
58
58
  date:
59
- - Mon, 14 May 2012 16:45:24 GMT
59
+ - Tue, 15 May 2012 18:36:13 GMT
60
60
  p3p:
61
61
  - policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
62
62
  set-cookie:
63
- - localization=en-us%3Bus%3Bus; expires=Mon, 12-May-2014 16:45:24 GMT; path=/; domain=.flickr.com
63
+ - localization=en-us%3Bus%3Bus; expires=Tue, 13-May-2014 18:36:13 GMT; path=/; domain=.flickr.com
64
64
  cache-control:
65
65
  - private
66
66
  x-served-by:
67
- - www214.flickr.mud.yahoo.com
67
+ - www43.flickr.mud.yahoo.com
68
68
  vary:
69
69
  - Accept-Encoding
70
70
  content-type:
@@ -72,16 +72,16 @@ http_interactions:
72
72
  age:
73
73
  - "0"
74
74
  via:
75
- - HTTP/1.1 r44.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r20.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
75
+ - HTTP/1.1 r41.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r17.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
76
76
  server:
77
77
  - YTS/1.20.16
78
78
  connection:
79
79
  - close
80
80
  body:
81
81
  encoding: ASCII-8BIT
82
- string: oauth_problem=signature_invalid&debug_sbs=GET&http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Frequest_token&oauth_callback%3Doob%26oauth_consumer_key%3DAPI_KEY%26oauth_nonce%3Dfd7c73dbb8eeabcc3a3827ff05e3620c%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1337013924%26oauth_version%3D1.0
82
+ string: oauth_problem=signature_invalid&debug_sbs=GET&http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Frequest_token&oauth_callback%3Doob%26oauth_consumer_key%3DAPI_KEY%26oauth_nonce%3D74d7fa04db335e2937437ae76ee1f0d7%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1337106973%26oauth_version%3D1.0
83
83
  http_version:
84
- recorded_at: Mon, 14 May 2012 16:45:25 GMT
84
+ recorded_at: Tue, 15 May 2012 18:36:13 GMT
85
85
  - request:
86
86
  method: get
87
87
  uri: http://www.flickr.com/services/oauth/request_token?oauth_callback=oob
@@ -90,39 +90,39 @@ http_interactions:
90
90
  string: ""
91
91
  headers:
92
92
  Authorization:
93
- - OAuth oauth_consumer_key="API_KEY", oauth_nonce="9c017e63fa165872fb6bdb47f67ced4c", oauth_signature="oHHbLzs%2B37XDu8X%2FZkDp7tjUuek%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337013925", oauth_version="1.0"
93
+ - OAuth oauth_consumer_key="API_KEY", oauth_nonce="f281211235ee00e5e804b0bced07db86", oauth_signature="FEFxXucnkU1vqcapGXSmFFQV3RA%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337106973", oauth_version="1.0"
94
94
  response:
95
95
  status:
96
96
  code: 200
97
97
  message:
98
98
  headers:
99
99
  date:
100
- - Mon, 14 May 2012 16:45:25 GMT
100
+ - Tue, 15 May 2012 18:36:13 GMT
101
101
  p3p:
102
102
  - policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
103
103
  set-cookie:
104
- - localization=en-us%3Bus%3Bus; expires=Mon, 12-May-2014 16:45:25 GMT; path=/; domain=.flickr.com
104
+ - localization=en-us%3Bus%3Bus; expires=Tue, 13-May-2014 18:36:14 GMT; path=/; domain=.flickr.com
105
105
  cache-control:
106
106
  - private
107
107
  x-served-by:
108
- - www86.flickr.mud.yahoo.com
108
+ - www197.flickr.mud.yahoo.com
109
109
  vary:
110
110
  - Accept-Encoding
111
111
  content-type:
112
112
  - text/plain;charset=UTF-8
113
113
  age:
114
- - "0"
114
+ - "3"
115
115
  via:
116
- - HTTP/1.1 r19.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r15.ycpi.dee.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
116
+ - HTTP/1.1 r27.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r08.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
117
117
  server:
118
118
  - YTS/1.20.16
119
119
  connection:
120
120
  - close
121
121
  body:
122
122
  encoding: ASCII-8BIT
123
- string: oauth_callback_confirmed=true&oauth_token=72157629726432998-b6e8086eed4dedfc&oauth_token_secret=1255246a9fb043cc
123
+ string: oauth_callback_confirmed=true&oauth_token=72157629743800246-00b99df825d26ba8&oauth_token_secret=c196d84eb9991116
124
124
  http_version:
125
- recorded_at: Mon, 14 May 2012 16:45:26 GMT
125
+ recorded_at: Tue, 15 May 2012 18:36:14 GMT
126
126
  - request:
127
127
  method: get
128
128
  uri: http://www.flickr.com/services/oauth/access_token?oauth_verifier=foo
@@ -131,22 +131,22 @@ http_interactions:
131
131
  string: ""
132
132
  headers:
133
133
  Authorization:
134
- - OAuth oauth_consumer_key="API_KEY", oauth_nonce="566aea9d42357131ea898b99198db774", oauth_signature="jITn0YkQQKofllBp0m3w8kOn%2Bqg%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337013926", oauth_token="72157629726432998-b6e8086eed4dedfc", oauth_version="1.0"
134
+ - OAuth oauth_consumer_key="API_KEY", oauth_nonce="269c50cc0bb64d4d1a6278ba0fd444a5", oauth_signature="%2FjkXnUp9knnhzs9zhRCmUM8%2FLJo%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1337106974", oauth_token="72157629743800246-00b99df825d26ba8", oauth_version="1.0"
135
135
  response:
136
136
  status:
137
137
  code: 401
138
138
  message:
139
139
  headers:
140
140
  date:
141
- - Mon, 14 May 2012 16:45:26 GMT
141
+ - Tue, 15 May 2012 18:36:15 GMT
142
142
  p3p:
143
143
  - policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
144
144
  set-cookie:
145
- - localization=en-us%3Bus%3Bus; expires=Mon, 12-May-2014 16:45:26 GMT; path=/; domain=.flickr.com
145
+ - localization=en-us%3Bus%3Bus; expires=Tue, 13-May-2014 18:36:15 GMT; path=/; domain=.flickr.com
146
146
  cache-control:
147
147
  - private
148
148
  x-served-by:
149
- - www131.flickr.mud.yahoo.com
149
+ - www111.flickr.mud.yahoo.com
150
150
  vary:
151
151
  - Accept-Encoding
152
152
  content-type:
@@ -154,7 +154,7 @@ http_interactions:
154
154
  age:
155
155
  - "0"
156
156
  via:
157
- - HTTP/1.1 r46.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r08.ycpi.ams.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
157
+ - HTTP/1.1 r23.ycpi.mud.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ]), HTTP/1.1 r10.ycpi.ukl.yahoo.net (YahooTrafficServer/1.20.16 [cMsSf ])
158
158
  server:
159
159
  - YTS/1.20.16
160
160
  connection:
@@ -163,5 +163,5 @@ http_interactions:
163
163
  encoding: ASCII-8BIT
164
164
  string: oauth_problem=token_rejected
165
165
  http_version:
166
- recorded_at: Mon, 14 May 2012 16:45:26 GMT
166
+ recorded_at: Tue, 15 May 2012 18:36:15 GMT
167
167
  recorded_with: VCR 2.1.1
@@ -2,23 +2,19 @@
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
3
3
 
4
4
  describe Flickrie::Instance do
5
- context "calling api methods" do
6
- use_vcr_cassette "instance/calling_api_methods"
5
+ it "should be able to call API methods", :vcr, :cassette => "calling api methods" do
6
+ # this is to see if the client and upload_client were reset
7
+ Flickrie.get_photo_info(PHOTO_ID)
8
+ Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
9
+ Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
10
+ id = Flickrie.upload(PHOTO_PATH)
11
+ Flickrie.delete_photo(id)
12
+ Flickrie.access_token = Flickrie.access_secret = nil
7
13
 
8
- it "should be able to call API methods" do
9
- # this is to see if the client and upload_client were reset
10
- Flickrie.get_photo_info(PHOTO_ID)
11
- Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
12
- Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
13
- id = Flickrie.upload(PHOTO_PATH)
14
- Flickrie.delete_photo(id)
15
- Flickrie.access_token = Flickrie.access_secret = nil
16
-
17
- instance = Flickrie::Instance.new(ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET'])
18
- user = instance.test_login
19
- user.username.should eq("Janko Marohnić")
20
- id = instance.upload(PHOTO_PATH)
21
- instance.delete_photo(id)
22
- end
14
+ instance = Flickrie::Instance.new(ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET'])
15
+ user = instance.test_login
16
+ user.username.should eq("Janko Marohnić")
17
+ id = instance.upload(PHOTO_PATH)
18
+ instance.delete_photo(id)
23
19
  end
24
20
  end
data/spec/license_spec.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
2
 
3
3
  describe Flickrie::License do
4
- context "get licenses" do
5
- use_vcr_cassette "license/get"
6
-
7
- it "should have all attributes correctly set" do
4
+ context "get" do
5
+ it "should have all attributes correctly set", :vcr do
8
6
  licenses = Flickrie.get_licenses
9
7
 
10
8
  licenses.each do |license|
@@ -2,9 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
2
 
3
3
  describe Flickrie::MediaCount do
4
4
  context "get" do
5
- use_vcr_cassette "media_count/get"
6
-
7
- it "should have correctly set all attributes" do
5
+ it "should have correctly set all attributes", :vcr do
8
6
  dates = [DateTime.parse("1st March 2012"), DateTime.parse("5th May 2012")].map(&:to_time)
9
7
  [
10
8
  @flickrie.get_media_counts(:taken_dates => dates.join(',')).first,
data/spec/media_spec.rb CHANGED
@@ -114,9 +114,7 @@ describe Flickrie::Media do
114
114
  end
115
115
 
116
116
  context "get info" do
117
- use_vcr_cassette "media/get_info"
118
-
119
- it "should have all attributes correctly set" do
117
+ it "should have all attributes correctly set", :vcr do
120
118
  [
121
119
  Flickrie.get_media_info(PHOTO_ID),
122
120
  Flickrie::Photo.public_new('id' => PHOTO_ID).get_info,
@@ -171,9 +169,8 @@ describe Flickrie::Media do
171
169
 
172
170
  context "from set" do
173
171
  include_context "common"
174
- use_vcr_cassette "media/from_set"
175
172
 
176
- it "should have all attributes correctly set" do
173
+ it "should have all attributes correctly set", :vcr do
177
174
  media = Flickrie.media_from_set(SET_ID, :extras => EXTRAS).
178
175
  find { |media| media.id == PHOTO_ID }
179
176
  test_common_attributes(media)
@@ -181,11 +178,21 @@ describe Flickrie::Media do
181
178
  end
182
179
  end
183
180
 
181
+ context "from user" do
182
+ include_context "common"
183
+
184
+ it "should have all attributes correctly set", :vcr do
185
+ media = @flickrie.media_from_user(USER_NSID, :extras => EXTRAS).
186
+ find { |media| media.id == PHOTO_ID }
187
+ test_common_attributes(media)
188
+ test_attribute(media, :visibility)
189
+ end
190
+ end
191
+
184
192
  context "public from user" do
185
193
  include_context "common"
186
- use_vcr_cassette "media/public_from_user"
187
194
 
188
- it "should have all attributes correctly set" do
195
+ it "should have all attributes correctly set", :vcr do
189
196
  media = Flickrie.public_media_from_user(USER_NSID, :extras => EXTRAS).
190
197
  find { |media| media.id == PHOTO_ID }
191
198
  test_common_attributes(media)
@@ -195,9 +202,8 @@ describe Flickrie::Media do
195
202
 
196
203
  context "search" do
197
204
  include_context "common"
198
- use_vcr_cassette "media/search"
199
205
 
200
- it "should have all attributes correctly set" do
206
+ it "should have all attributes correctly set", :vcr do
201
207
  media = Flickrie.search_media(:user_id => USER_NSID, :extras => EXTRAS).
202
208
  find { |media| media.id == PHOTO_ID }
203
209
  test_common_attributes(media)
@@ -206,9 +212,7 @@ describe Flickrie::Media do
206
212
  end
207
213
 
208
214
  context "from contacts" do
209
- use_vcr_cassette "media/from_contacts"
210
-
211
- it "should have all attributes correctly set" do
215
+ it "should have all attributes correctly set", :vcr do
212
216
  params = {:include_self => 1, :single_photo => 1}
213
217
  [
214
218
  @flickrie.media_from_contacts(params).first,
@@ -229,9 +233,7 @@ describe Flickrie::Media do
229
233
  end
230
234
 
231
235
  context "get context" do
232
- use_vcr_cassette "media/get_context"
233
-
234
- it "should have all attributes correctly set" do
236
+ it "should have all attributes correctly set", :vcr do
235
237
  context = Flickrie.get_media_context(PHOTO_ID)
236
238
  context['count'].should eq(98)
237
239
  context['prevphoto'].title.should eq('IMG_0795')
@@ -254,9 +256,7 @@ describe Flickrie::Media do
254
256
  end
255
257
 
256
258
  context "get exif" do
257
- use_vcr_cassette "media/get_exif"
258
-
259
- it "should get exif correctly" do
259
+ it "should get exif correctly", :vcr do
260
260
  [
261
261
  Flickrie.get_photo_exif(PHOTO_ID),
262
262
  Flickrie::Photo.public_new('id' => PHOTO_ID).get_exif
data/spec/oauth_spec.rb CHANGED
@@ -2,9 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
2
 
3
3
  describe Flickrie::OAuth do
4
4
  context "incorrect credentials" do
5
- use_vcr_cassette "oauth/incorrect_credentials"
6
-
7
- it "should raise exceptions" do
5
+ it "should raise exceptions", :vcr do
8
6
  Flickrie.api_key = "foo"
9
7
  Flickrie.shared_secret = "foo"
10
8
 
data/spec/photo_spec.rb CHANGED
@@ -53,9 +53,7 @@ describe Flickrie::Photo do
53
53
  end
54
54
 
55
55
  context "get sizes" do
56
- use_vcr_cassette "photo/get_sizes"
57
-
58
- it "should have attributes correctly set" do
56
+ it "should have attributes correctly set", :vcr do
59
57
  [
60
58
  Flickrie.get_photo_sizes(PHOTO_ID),
61
59
  Flickrie::Photo.public_new('id' => PHOTO_ID).get_sizes
@@ -72,9 +70,7 @@ describe Flickrie::Photo do
72
70
  end
73
71
 
74
72
  context "search" do
75
- use_vcr_cassette "photo/search"
76
-
77
- it "should have all sizes available" do
73
+ it "should have all sizes available", :vcr do
78
74
  photo = Flickrie.search_photos(:user_id => USER_NSID, :extras => EXTRAS).
79
75
  find { |photo| photo.id == PHOTO_ID }
80
76
  photo.available_sizes.should eq(SIZES)
@@ -82,9 +78,7 @@ describe Flickrie::Photo do
82
78
  end
83
79
 
84
80
  context "get info" do
85
- use_vcr_cassette "photo/get_info"
86
-
87
- it "should have all attributes correctly set" do
81
+ it "should have all attributes correctly set", :vcr do
88
82
  photo = Flickrie.get_photo_info(PHOTO_ID)
89
83
  photo.rotation.should eq(90)
90
84
  end
data/spec/set_spec.rb CHANGED
@@ -43,9 +43,7 @@ describe Flickrie::Set do
43
43
  end
44
44
 
45
45
  context "get info" do
46
- use_vcr_cassette "set/get_info"
47
-
48
- it "should have all attributes correctly set" do
46
+ it "should have all attributes correctly set", :vcr do
49
47
  [
50
48
  Flickrie.get_set_info(SET_ID),
51
49
  Flickrie::Set.public_new('id' => SET_ID).get_info
@@ -57,9 +55,7 @@ describe Flickrie::Set do
57
55
  end
58
56
 
59
57
  context "from user" do
60
- use_vcr_cassette "set/from_user"
61
-
62
- it "should have all attributes correctly set" do
58
+ it "should have all attributes correctly set", :vcr do
63
59
  set = Flickrie.sets_from_user(USER_NSID).find { |set| set.id == SET_ID }
64
60
  test_common_attributes(set)
65
61
  set.needs_interstitial?.should be_false
data/spec/spec_helper.rb CHANGED
@@ -5,18 +5,6 @@ begin
5
5
  rescue LoadError
6
6
  end
7
7
 
8
- VCR.configure do |config|
9
- config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
10
- config.hook_into :faraday
11
- config.default_cassette_options = {
12
- :record => :new_episodes,
13
- :serialize_with => :syck,
14
- :match_requests_on => [:method, VCR.request_matchers.uri_without_param(:api_key)]
15
- }
16
- config.filter_sensitive_data('API_KEY') { ENV['FLICKR_API_KEY'] }
17
- config.filter_sensitive_data('ACCESS_TOKEN') { ENV['FLICKR_ACCESS_TOKEN'] }
18
- end
19
-
20
8
  module RSpecHelpers
21
9
  def test_attribute(object, attribute, hash = nil)
22
10
  expectation = hash || @attributes[attribute]
@@ -40,16 +28,42 @@ module RSpecHelpers
40
28
  end
41
29
  end
42
30
 
43
- RSpec.configure do |config|
44
- config.extend VCR::RSpec::Macros
45
- config.include RSpecHelpers
46
- config.before(:all) do
31
+ RSpec.configure do |c|
32
+ c.include RSpecHelpers
33
+ c.before(:all) do
47
34
  Flickrie.api_key = ENV['FLICKR_API_KEY']
48
35
  Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
49
36
  # so that I can use the '@instance' object when I want to make authenticated API calls
50
37
  @flickrie = Flickrie::Instance.new(ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET'])
51
38
  end
52
- config.fail_fast = true
39
+ c.treat_symbols_as_metadata_keys_with_true_values = true
40
+ c.around(:each, :vcr) do |example|
41
+ if example.metadata[:cassette].nil?
42
+ # the example is also wrapped in a 'context' block
43
+ class_name = example.metadata[:example_group][:example_group][:description_args].first.to_s
44
+ cassette_name = example.metadata[:example_group][:description_args].first
45
+ else
46
+ # the example isn't wrapped in a 'context' block
47
+ class_name = example.metadata[:example_group][:description_args].first.to_s
48
+ cassette_name = example.metadata[:cassette]
49
+ end
50
+
51
+ folder = class_name.to_s.match(/^Flickrie::/).post_match.to_file_path
52
+ VCR.use_cassette("#{folder}/#{cassette_name}") { example.call }
53
+ end
54
+ c.fail_fast = true
55
+ end
56
+
57
+ VCR.configure do |c|
58
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
59
+ c.hook_into :faraday
60
+ c.default_cassette_options = {
61
+ :record => :new_episodes,
62
+ :serialize_with => :syck,
63
+ :match_requests_on => [:method, VCR.request_matchers.uri_without_param(:api_key)]
64
+ }
65
+ c.filter_sensitive_data('API_KEY') { ENV['FLICKR_API_KEY'] }
66
+ c.filter_sensitive_data('ACCESS_TOKEN') { ENV['FLICKR_ACCESS_TOKEN'] }
53
67
  end
54
68
 
55
69
  PHOTO_PATH = File.join(File.expand_path(File.dirname(__FILE__)), 'files/photo.jpg').freeze
@@ -83,3 +97,9 @@ class Hash
83
97
  self.dup.except!(*keys)
84
98
  end
85
99
  end
100
+
101
+ class String
102
+ def to_file_path
103
+ split("::").collect { |klass| klass.split(/(?=[A-Z])/).map(&:downcase).join('_') }.join('/')
104
+ end
105
+ end
data/spec/user_spec.rb CHANGED
@@ -3,9 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
3
3
 
4
4
  describe Flickrie::User do
5
5
  context "get info" do
6
- use_vcr_cassette "user/get_info"
7
-
8
- it "should have all attributes correctly set" do
6
+ it "should have all attributes correctly set", :vcr do
9
7
  [
10
8
  Flickrie.get_user_info(USER_NSID),
11
9
  Flickrie::User.public_new('nsid' => USER_NSID).get_info
@@ -40,9 +38,7 @@ describe Flickrie::User do
40
38
  end
41
39
 
42
40
  context "find by username or email" do
43
- use_vcr_cassette "user/find_by_username_or_email"
44
-
45
- it "should have all attributes correctly set" do
41
+ it "should have all attributes correctly set", :vcr do
46
42
  [
47
43
  Flickrie.find_user_by_username('Janko Marohnić'),
48
44
  Flickrie.find_user_by_email('janko.marohnic@gmail.com')
data/spec/video_spec.rb CHANGED
@@ -2,9 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
2
 
3
3
  describe Flickrie::Video do
4
4
  context "get info" do
5
- use_vcr_cassette "video/get_info"
6
-
7
- it "should have all attributes correctly set" do
5
+ it "should have all attributes correctly set", :vcr do
8
6
  video = Flickrie.get_video_info(VIDEO_ID)
9
7
 
10
8
  video.ready?.should be_true
@@ -22,9 +20,7 @@ describe Flickrie::Video do
22
20
  end
23
21
 
24
22
  context "get sizes" do
25
- use_vcr_cassette "video/get_sizes"
26
-
27
- it "should have all attributes correctly set" do
23
+ it "should have all attributes correctly set", :vcr do
28
24
  [
29
25
  Flickrie.get_video_sizes(VIDEO_ID),
30
26
  Flickrie::Video.public_new('id' => VIDEO_ID).get_sizes