pinboard_api 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.travis.yml +2 -1
  2. data/README.md +26 -6
  3. data/lib/core_ext/blank.rb +26 -0
  4. data/lib/pinboard_api.rb +8 -2
  5. data/lib/pinboard_api/exceptions.rb +5 -0
  6. data/lib/pinboard_api/post.rb +54 -40
  7. data/lib/pinboard_api/request_utils.rb +22 -0
  8. data/lib/pinboard_api/tag.rb +10 -8
  9. data/lib/pinboard_api/version.rb +1 -1
  10. data/spec/core_ext/blank_spec.rb +19 -0
  11. data/spec/exceptions_spec.rb +7 -0
  12. data/spec/pinboard_api_spec.rb +9 -6
  13. data/spec/post_spec.rb +124 -42
  14. data/spec/support/pinboard_configuration.rb +1 -0
  15. data/spec/support/request_utils_spec.rb +29 -0
  16. data/spec/support/vcr.rb +13 -3
  17. data/spec/tag_spec.rb +15 -13
  18. data/spec/user_spec.rb +1 -5
  19. data/spec/vcr_cassettes/posts/all/custom_count.json +1 -0
  20. data/spec/vcr_cassettes/posts/all/custom_tag.json +1 -0
  21. data/spec/vcr_cassettes/posts/all/custom_times.json +1 -0
  22. data/spec/vcr_cassettes/posts/all/default_values.json +1 -0
  23. data/spec/vcr_cassettes/posts/all/not_found.json +1 -0
  24. data/spec/vcr_cassettes/posts/all/with_meta.json +1 -0
  25. data/spec/vcr_cassettes/posts/create.json +1 -0
  26. data/spec/vcr_cassettes/posts/dates/custom_tag.json +1 -0
  27. data/spec/vcr_cassettes/posts/dates/default_values.json +1 -0
  28. data/spec/vcr_cassettes/posts/delete/unsuccessful_class.json +1 -0
  29. data/spec/vcr_cassettes/posts/destroy/successful_class.json +1 -0
  30. data/spec/vcr_cassettes/posts/destroy/successful_instance.json +1 -0
  31. data/spec/vcr_cassettes/posts/destroy/unsuccessful_instance.json +1 -0
  32. data/spec/vcr_cassettes/posts/find/found.json +1 -0
  33. data/spec/vcr_cassettes/posts/find/not_found.json +1 -0
  34. data/spec/vcr_cassettes/posts/recent/custom_count.json +1 -0
  35. data/spec/vcr_cassettes/posts/recent/custom_tag.json +1 -0
  36. data/spec/vcr_cassettes/posts/recent/default_values.json +1 -0
  37. data/spec/vcr_cassettes/posts/save.json +1 -0
  38. data/spec/vcr_cassettes/posts/suggest.json +1 -0
  39. data/spec/vcr_cassettes/posts/update.json +1 -0
  40. data/spec/vcr_cassettes/tags/all.json +1 -0
  41. data/spec/vcr_cassettes/tags/destroy/successful_class.json +1 -0
  42. data/spec/vcr_cassettes/tags/destroy/successful_instance.json +1 -0
  43. data/spec/vcr_cassettes/tags/destroy/unsuccessful_class.json +1 -0
  44. data/spec/vcr_cassettes/tags/destroy/unsuccessful_instance.json +1 -0
  45. data/spec/vcr_cassettes/tags/find/found.json +1 -0
  46. data/spec/vcr_cassettes/tags/find/not_found.json +1 -0
  47. data/spec/vcr_cassettes/tags/rename/successful.json +1 -0
  48. data/spec/vcr_cassettes/tags/rename/unsuccessful.json +1 -0
  49. data/spec/vcr_cassettes/user/secret.json +1 -0
  50. metadata +73 -58
  51. data/spec/fixtures/vcr_cassettes/posts/all/custom_count.json +0 -1
  52. data/spec/fixtures/vcr_cassettes/posts/all/custom_tag.json +0 -1
  53. data/spec/fixtures/vcr_cassettes/posts/all/custom_times.json +0 -1
  54. data/spec/fixtures/vcr_cassettes/posts/all/default_values.json +0 -1
  55. data/spec/fixtures/vcr_cassettes/posts/all/not_found.json +0 -1
  56. data/spec/fixtures/vcr_cassettes/posts/dates/custom_tag.json +0 -1
  57. data/spec/fixtures/vcr_cassettes/posts/dates/default_values.json +0 -1
  58. data/spec/fixtures/vcr_cassettes/posts/delete/unsuccessful_class.json +0 -1
  59. data/spec/fixtures/vcr_cassettes/posts/destroy/successful_class.json +0 -1
  60. data/spec/fixtures/vcr_cassettes/posts/destroy/successful_instance.json +0 -1
  61. data/spec/fixtures/vcr_cassettes/posts/destroy/unsuccessful_instance.json +0 -1
  62. data/spec/fixtures/vcr_cassettes/posts/find/found.json +0 -1
  63. data/spec/fixtures/vcr_cassettes/posts/find/not_found.json +0 -1
  64. data/spec/fixtures/vcr_cassettes/posts/recent/custom_count.json +0 -1
  65. data/spec/fixtures/vcr_cassettes/posts/recent/custom_tag.json +0 -1
  66. data/spec/fixtures/vcr_cassettes/posts/recent/default_values.json +0 -1
  67. data/spec/fixtures/vcr_cassettes/posts/suggest.json +0 -1
  68. data/spec/fixtures/vcr_cassettes/posts/update.json +0 -1
  69. data/spec/fixtures/vcr_cassettes/tags/all.json +0 -1
  70. data/spec/fixtures/vcr_cassettes/tags/destroy/successful_class.json +0 -1
  71. data/spec/fixtures/vcr_cassettes/tags/destroy/successful_instance.json +0 -1
  72. data/spec/fixtures/vcr_cassettes/tags/destroy/unsuccessful_class.json +0 -1
  73. data/spec/fixtures/vcr_cassettes/tags/destroy/unsuccessful_instance.json +0 -1
  74. data/spec/fixtures/vcr_cassettes/tags/find/found.json +0 -1
  75. data/spec/fixtures/vcr_cassettes/tags/find/not_found.json +0 -1
  76. data/spec/fixtures/vcr_cassettes/tags/rename/successful.json +0 -1
  77. data/spec/fixtures/vcr_cassettes/tags/rename/unsuccessful.json +0 -1
  78. data/spec/fixtures/vcr_cassettes/user/secret.json +0 -1
@@ -59,13 +59,91 @@ describe PinboardApi::Post do
59
59
  end
60
60
 
61
61
 
62
+ # #######################
63
+ # save
64
+ # #######################
65
+ describe "#save" do
66
+ describe "success" do
67
+ let(:url) { "http://phlippers.net/pinboard_api" }
68
+ let(:description) { "A Ruby client for the Pinboard.in API" }
69
+ let(:extended) { "Extended Awesomeness" }
70
+ let(:tags) { %w[ruby programming] }
71
+
72
+ before do
73
+ PinboardApi::VCR.use_cassette("posts/save") do
74
+ post.destroy(url: url) rescue nil # make sure it adds one
75
+ params = {
76
+ url: url, description: description, extended: extended, tags: tags
77
+ }
78
+ @post1 = post.new(params).save
79
+ @post2 = post.find(url: url).first
80
+ end
81
+ end
82
+
83
+ it { @post1.must_be_kind_of PinboardApi::Post }
84
+ it { @post1.url.must_equal url }
85
+ it { @post1.description.must_equal description }
86
+ it { @post1.extended.must_equal extended }
87
+ it { @post1.tags.must_equal tags }
88
+
89
+ it { @post2.url.must_equal @post1.url }
90
+ it { @post2.description.must_equal @post1.description }
91
+ it { @post2.extended.must_equal @post1.extended }
92
+ it { @post2.tags.must_equal @post1.tags }
93
+ end
94
+
95
+ describe "failure" do
96
+ it { -> { post.new.save }.must_raise(PinboardApi::InvalidPostError) }
97
+ end
98
+ end
99
+
100
+
101
+ # #######################
102
+ # self.create
103
+ # #######################
104
+ describe "self.create" do
105
+ describe "success" do
106
+ let(:url) { "https://github.com/phlipper/pinboard_api" }
107
+ let(:description) { "PinboardAPI on Github" }
108
+ let(:extended) { "Extended Github Awesomeness" }
109
+ let(:tags) { %w[pinboard github] }
110
+
111
+ before do
112
+ PinboardApi::VCR.use_cassette("posts/create") do
113
+ post.destroy(url: url) rescue nil # make sure it adds one
114
+ params = {
115
+ url: url, description: description, extended: extended, tags: tags
116
+ }
117
+ @post1 = post.create(params)
118
+ @post2 = post.find(url: url).first
119
+ end
120
+ end
121
+
122
+ it { @post1.must_be_kind_of PinboardApi::Post }
123
+ it { @post1.url.must_equal url }
124
+ it { @post1.description.must_equal description }
125
+ it { @post1.extended.must_equal extended }
126
+ it { @post1.tags.must_equal tags }
127
+
128
+ it { @post2.url.must_equal @post1.url }
129
+ it { @post2.description.must_equal @post1.description }
130
+ it { @post2.extended.must_equal @post1.extended }
131
+ it { @post2.tags.must_equal @post1.tags }
132
+ end
133
+
134
+ describe "failure" do
135
+ it { -> { post.create({}) }.must_raise(PinboardApi::InvalidPostError) }
136
+ end
137
+ end
138
+
139
+
62
140
  # #######################
63
141
  # destroy
64
142
  # #######################
65
143
  describe "#destroy" do
66
144
  describe "when successful" do
67
145
  it "returns self" do
68
- VCR.use_cassette("posts/destroy/successful_instance") do
146
+ PinboardApi::VCR.use_cassette("posts/destroy/successful_instance") do
69
147
  post = PinboardApi::Post.find(url: "http://duckduckgo.com/").first
70
148
  post.destroy.must_equal post
71
149
  end
@@ -75,22 +153,33 @@ describe PinboardApi::Post do
75
153
  describe "when not successful" do
76
154
  it "raises an exception" do
77
155
  Faraday::Response.any_instance.stubs(:body).returns("")
78
- VCR.use_cassette("posts/destroy/unsuccessful_instance") do
156
+ PinboardApi::VCR.use_cassette("posts/destroy/unsuccessful_instance") do
79
157
  post = PinboardApi::Post.new
80
- -> { post.destroy }.must_raise(RuntimeError)
158
+ -> { post.destroy }.must_raise(PinboardApi::InvalidResponseError)
81
159
  end
82
160
  end
83
161
  end
84
162
  end
85
163
 
86
164
 
165
+ # #######################
166
+ # validate!
167
+ # #######################
168
+ describe "validate!" do
169
+ let(:exception) { PinboardApi::InvalidPostError }
170
+
171
+ it { -> { post.new.validate! }.must_raise(exception) }
172
+ it { -> { post.new(url: "x").validate! }.must_raise(exception) }
173
+ end
174
+
175
+
87
176
  # #######################
88
177
  # self.destroy
89
178
  # #######################
90
179
  describe "self.destroy" do
91
180
  describe "when successful" do
92
181
  it "returns self" do
93
- VCR.use_cassette("posts/destroy/successful_class") do
182
+ PinboardApi::VCR.use_cassette("posts/destroy/successful_class") do
94
183
  post = PinboardApi::Post.destroy("http://www.bing.com/")
95
184
  post.must_be_kind_of PinboardApi::Post
96
185
  end
@@ -100,8 +189,10 @@ describe PinboardApi::Post do
100
189
  describe "when not successful" do
101
190
  it "raises an exception" do
102
191
  Faraday::Response.any_instance.stubs(:body).returns("")
103
- VCR.use_cassette("posts/delete/unsuccessful_class") do
104
- -> { PinboardApi::Post.destroy("xxBOGUSxxINVALIDxx") }.must_raise(RuntimeError)
192
+ PinboardApi::VCR.use_cassette("posts/delete/unsuccessful_class") do
193
+ -> {
194
+ PinboardApi::Post.destroy("xxBOGUSxxINVALIDxx")
195
+ }.must_raise(PinboardApi::InvalidResponseError)
105
196
  end
106
197
  end
107
198
  end
@@ -115,7 +206,7 @@ describe PinboardApi::Post do
115
206
  describe "found" do
116
207
  describe "with default values" do
117
208
  before do
118
- VCR.use_cassette("posts/all/default_values", preserve_exact_body_bytes: true) do
209
+ PinboardApi::VCR.use_cassette("posts/all/default_values") do
119
210
  @posts = PinboardApi::Post.all
120
211
  end
121
212
  end
@@ -127,7 +218,7 @@ describe PinboardApi::Post do
127
218
 
128
219
  describe "with custom count" do
129
220
  before do
130
- VCR.use_cassette("posts/all/custom_count", preserve_exact_body_bytes: true) do
221
+ PinboardApi::VCR.use_cassette("posts/all/custom_count") do
131
222
  @posts = PinboardApi::Post.all(results: 3)
132
223
  end
133
224
  end
@@ -139,7 +230,7 @@ describe PinboardApi::Post do
139
230
 
140
231
  describe "with custom tag" do
141
232
  before do
142
- VCR.use_cassette("posts/all/custom_tag", preserve_exact_body_bytes: true) do
233
+ PinboardApi::VCR.use_cassette("posts/all/custom_tag") do
143
234
  @posts = PinboardApi::Post.all(tag: %w[ruby programming])
144
235
  end
145
236
  @tags = @posts.map(&:tags).flatten
@@ -150,12 +241,23 @@ describe PinboardApi::Post do
150
241
  it { @tags.must_include "programming" }
151
242
  end
152
243
 
244
+ describe "with meta" do
245
+ before do
246
+ PinboardApi::VCR.use_cassette("posts/all/with_meta") do
247
+ @posts = PinboardApi::Post.all(meta: true)
248
+ end
249
+ end
250
+
251
+ it { @posts.must_be_kind_of Array }
252
+ it { @posts.first.meta.wont_be_empty }
253
+ end
254
+
153
255
  describe "with custom times" do
154
- let(:fromdt) { Time.new(2012, 05, 01).utc }
155
- let(:todt) { Time.new(2012, 06, 01).utc }
256
+ let(:fromdt) { Time.gm(2012, 05, 01) }
257
+ let(:todt) { Time.gm(2012, 06, 01) }
156
258
 
157
259
  before do
158
- VCR.use_cassette("posts/all/custom_times", preserve_exact_body_bytes: true) do
260
+ PinboardApi::VCR.use_cassette("posts/all/custom_times") do
159
261
  @posts = PinboardApi::Post.all(fromdt: fromdt, todt: todt)
160
262
  end
161
263
  @times = @posts.map(&:time).flatten
@@ -168,7 +270,7 @@ describe PinboardApi::Post do
168
270
 
169
271
  describe "not found" do
170
272
  before do
171
- VCR.use_cassette("posts/all/not_found") do
273
+ PinboardApi::VCR.use_cassette("posts/all/not_found") do
172
274
  @posts = PinboardApi::Post.all(tag: "xxNOTxxFOUNDxx")
173
275
  end
174
276
  end
@@ -184,7 +286,7 @@ describe PinboardApi::Post do
184
286
  describe "self.find" do
185
287
  describe "found" do
186
288
  before do
187
- VCR.use_cassette("posts/find/found", preserve_exact_body_bytes: true) do
289
+ PinboardApi::VCR.use_cassette("posts/find/found") do
188
290
  @posts = PinboardApi::Post.find(tag: "test")
189
291
  end
190
292
  end
@@ -196,7 +298,7 @@ describe PinboardApi::Post do
196
298
 
197
299
  describe "not found" do
198
300
  before do
199
- VCR.use_cassette("posts/find/not_found") do
301
+ PinboardApi::VCR.use_cassette("posts/find/not_found") do
200
302
  @posts = PinboardApi::Post.find(tag: "xxBOGUSxxINVALIDxx")
201
303
  end
202
304
  end
@@ -211,7 +313,7 @@ describe PinboardApi::Post do
211
313
  # #######################
212
314
  describe "self.last_update" do
213
315
  before do
214
- VCR.use_cassette("posts/update") do
316
+ PinboardApi::VCR.use_cassette("posts/update") do
215
317
  @last_update = PinboardApi::Post.last_update
216
318
  end
217
319
  end
@@ -225,7 +327,7 @@ describe PinboardApi::Post do
225
327
  # #######################
226
328
  describe "self.suggest" do
227
329
  before do
228
- VCR.use_cassette("posts/suggest") do
330
+ PinboardApi::VCR.use_cassette("posts/suggest") do
229
331
  @suggestions = PinboardApi::Post.suggest("http://blog.com")
230
332
  end
231
333
  end
@@ -244,7 +346,7 @@ describe PinboardApi::Post do
244
346
  describe "self.recent" do
245
347
  describe "with default values" do
246
348
  before do
247
- VCR.use_cassette("posts/recent/default_values", preserve_exact_body_bytes: true) do
349
+ PinboardApi::VCR.use_cassette("posts/recent/default_values") do
248
350
  @posts = PinboardApi::Post.recent
249
351
  end
250
352
  end
@@ -256,7 +358,7 @@ describe PinboardApi::Post do
256
358
 
257
359
  describe "with custom count" do
258
360
  before do
259
- VCR.use_cassette("posts/recent/custom_count", preserve_exact_body_bytes: true) do
361
+ PinboardApi::VCR.use_cassette("posts/recent/custom_count") do
260
362
  @posts = PinboardApi::Post.recent(count: 3)
261
363
  end
262
364
  end
@@ -268,7 +370,7 @@ describe PinboardApi::Post do
268
370
 
269
371
  describe "with custom tag" do
270
372
  before do
271
- VCR.use_cassette("posts/recent/custom_tag", preserve_exact_body_bytes: true) do
373
+ PinboardApi::VCR.use_cassette("posts/recent/custom_tag") do
272
374
  @posts = PinboardApi::Post.recent(tag: %w[ruby programming])
273
375
  end
274
376
  @tags = @posts.map(&:tags).flatten
@@ -287,7 +389,7 @@ describe PinboardApi::Post do
287
389
  describe "self.dates" do
288
390
  describe "with default values" do
289
391
  before do
290
- VCR.use_cassette("posts/dates/default_values", preserve_exact_body_bytes: true) do
392
+ PinboardApi::VCR.use_cassette("posts/dates/default_values") do
291
393
  @dates = PinboardApi::Post.dates
292
394
  end
293
395
  @date = @dates.first
@@ -303,7 +405,7 @@ describe PinboardApi::Post do
303
405
 
304
406
  describe "with custom tag" do
305
407
  before do
306
- VCR.use_cassette("posts/dates/custom_tag", preserve_exact_body_bytes: true) do
408
+ PinboardApi::VCR.use_cassette("posts/dates/custom_tag") do
307
409
  @all_dates = PinboardApi::Post.dates
308
410
  @tag_dates = PinboardApi::Post.dates(tag: "ruby")
309
411
  end
@@ -392,24 +494,4 @@ describe PinboardApi::Post do
392
494
  it { @urls.must_include "http://www.baz.qux" }
393
495
  end
394
496
  end
395
-
396
- # #######################
397
- # self.dt_param_string
398
- # #######################
399
- describe "self.dt_param_string" do
400
- let(:time) { Time.new(2012, 01, 01, 0, 0, 0, 0) }
401
-
402
- it { post.dt_param_string(nil).must_be_nil }
403
- it { post.dt_param_string(time).must_equal "2012-01-01T00:00:00Z" }
404
- end
405
-
406
- # #######################
407
- # self.tag_param_string
408
- # #######################
409
- describe "self.tag_param_string" do
410
- it { post.tag_param_string(nil).must_be_nil }
411
- it { post.tag_param_string("foo").must_equal "foo" }
412
- it { post.tag_param_string("foo,bar").must_equal "foo,bar" }
413
- it { post.tag_param_string(%w[foo bar]).must_equal "foo,bar" }
414
- end
415
497
  end
@@ -1,5 +1,6 @@
1
1
  PinboardApi.username = ENV["PINBOARD_USERNAME"]
2
2
  PinboardApi.password = ENV["PINBOARD_PASSWORD"]
3
+ PinboardApi.auth_token = ENV["PINBOARD_AUTH_TOKEN"]
3
4
 
4
5
  PinboardApi.ssl_options = ENV["PINBOARD_SSL_OPTIONS"] || begin
5
6
  if File.exists?("/opt/local/share/curl/curl-ca-bundle.crt")
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe PinboardApi::RequestUtils do
4
+ before do
5
+ class Helper
6
+ include PinboardApi::RequestUtils
7
+ end
8
+ end
9
+
10
+ describe "yes_no" do
11
+ it { Helper.new.yes_no(nil).must_be_nil }
12
+ it { Helper.new.yes_no(true).must_equal "yes" }
13
+ it { Helper.new.yes_no(false).must_equal "no" }
14
+ end
15
+
16
+ describe "self.dt_param_string" do
17
+ let(:time) { Time.new(2012, 01, 01, 0, 0, 0, 0) }
18
+
19
+ it { Helper.dt_param_string(nil).must_be_nil }
20
+ it { Helper.dt_param_string(time).must_equal "2012-01-01T00:00:00Z" }
21
+ end
22
+
23
+ describe "self.tag_param_string" do
24
+ it { Helper.tag_param_string(nil).must_be_nil }
25
+ it { Helper.tag_param_string("foo").must_equal "foo" }
26
+ it { Helper.tag_param_string("foo,bar").must_equal "foo,bar" }
27
+ it { Helper.tag_param_string(%w[foo bar]).must_equal "foo,bar" }
28
+ end
29
+ end
@@ -4,11 +4,21 @@ require "base64"
4
4
  VCR.configure do |c|
5
5
  c.default_cassette_options = { record: :once, serialize_with: :json }
6
6
  c.hook_into :faraday
7
- c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
8
- c.filter_sensitive_data("[USERNAME]") { PinboardApi.username }
9
- c.filter_sensitive_data("[PASSWORD]") { PinboardApi.password }
7
+ c.cassette_library_dir = "spec/vcr_cassettes"
8
+ c.filter_sensitive_data("[USERNAME]") { PinboardApi.username }
9
+ c.filter_sensitive_data("[PASSWORD]") { PinboardApi.password }
10
+ c.filter_sensitive_data("[AUTHTOKEN]") { PinboardApi.auth_token }
10
11
  c.filter_sensitive_data("[FILTERED]") do
11
12
  credentials = [PinboardApi.username, PinboardApi.password].join(":")
12
13
  Base64.encode64(credentials).chomp
13
14
  end
14
15
  end
16
+
17
+ module PinboardApi
18
+ class VCR
19
+ def self.use_cassette(name, options = {}, &block)
20
+ options.merge!(preserve_exact_body_bytes: true)
21
+ ::VCR.use_cassette name, options, &block
22
+ end
23
+ end
24
+ end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe PinboardApi::Tag do
4
- let(:tag) { PinboardApi::Tag.new({"name" => "tag", "count" => 1}) }
4
+ let(:tag) { PinboardApi::Tag.new(name: "tag", count: 1) }
5
5
 
6
6
  it { tag.must_respond_to :name }
7
7
  it { tag.name.must_equal "tag" }
@@ -12,7 +12,7 @@ describe PinboardApi::Tag do
12
12
 
13
13
  describe "self.all" do
14
14
  before do
15
- VCR.use_cassette("tags/all") do
15
+ PinboardApi::VCR.use_cassette("tags/all") do
16
16
  @tags = PinboardApi::Tag.all
17
17
  end
18
18
  end
@@ -27,7 +27,7 @@ describe PinboardApi::Tag do
27
27
  describe "self.find" do
28
28
  describe "found" do
29
29
  before do
30
- VCR.use_cassette("tags/find/found") do
30
+ PinboardApi::VCR.use_cassette("tags/find/found") do
31
31
  @tags = PinboardApi::Tag.all
32
32
  @tag = PinboardApi::Tag.find(@tags.first.name)
33
33
  end
@@ -39,7 +39,7 @@ describe PinboardApi::Tag do
39
39
 
40
40
  describe "not found" do
41
41
  before do
42
- VCR.use_cassette("tags/find/not_found") do
42
+ PinboardApi::VCR.use_cassette("tags/find/not_found") do
43
43
  @tag = PinboardApi::Tag.find("xxBOGUSxxINVALIDxx")
44
44
  end
45
45
  end
@@ -52,7 +52,7 @@ describe PinboardApi::Tag do
52
52
  describe "#rename" do
53
53
  describe "when successful" do
54
54
  before do
55
- VCR.use_cassette("tags/rename/successful") do
55
+ PinboardApi::VCR.use_cassette("tags/rename/successful") do
56
56
  tag = PinboardApi::Tag.all.first
57
57
  @new_name = "z_#{tag.name}"
58
58
  @new_tag = tag.rename(@new_name)
@@ -64,9 +64,9 @@ describe PinboardApi::Tag do
64
64
 
65
65
  describe "when rename fails" do
66
66
  it "raises an exception" do
67
- VCR.use_cassette("tags/rename/unsuccessful") do
67
+ PinboardApi::VCR.use_cassette("tags/rename/unsuccessful") do
68
68
  @tag = PinboardApi::Tag.all.first
69
- -> { @tag.rename("") }.must_raise(RuntimeError)
69
+ -> { @tag.rename("") }.must_raise(PinboardApi::InvalidResponseError)
70
70
  end
71
71
  end
72
72
  end
@@ -76,7 +76,7 @@ describe PinboardApi::Tag do
76
76
  describe "#destroy" do
77
77
  describe "when successful" do
78
78
  it "returns self when the remote tag has been destroyed" do
79
- VCR.use_cassette("tags/destroy/successful_instance") do
79
+ PinboardApi::VCR.use_cassette("tags/destroy/successful_instance") do
80
80
  tag = PinboardApi::Tag.find("junk")
81
81
  tag.destroy.must_equal tag
82
82
  end
@@ -87,9 +87,9 @@ describe PinboardApi::Tag do
87
87
  describe "when not successful" do
88
88
  it "raises an exception" do
89
89
  Faraday::Response.any_instance.stubs(:body).returns("")
90
- VCR.use_cassette("tags/destroy/unsuccessful_instance") do
91
- tag = PinboardApi::Tag.new("name" => "xxINVALIDxxBOGUSxx", "count" => 1)
92
- -> { tag.destroy }.must_raise(RuntimeError)
90
+ PinboardApi::VCR.use_cassette("tags/destroy/unsuccessful_instance") do
91
+ tag = PinboardApi::Tag.new(name: "xxINVALIDxxBOGUSxx", count: 1)
92
+ -> { tag.destroy }.must_raise(PinboardApi::InvalidResponseError)
93
93
  end
94
94
  end
95
95
  end
@@ -98,7 +98,7 @@ describe PinboardApi::Tag do
98
98
  describe "self.destroy" do
99
99
  describe "when successful" do
100
100
  it "returns self when the remote tag has been destroyed" do
101
- VCR.use_cassette("tags/destroy/successful_class") do
101
+ PinboardApi::VCR.use_cassette("tags/destroy/successful_class") do
102
102
  tag = PinboardApi::Tag.destroy("junk")
103
103
  tag.must_be_kind_of PinboardApi::Tag
104
104
  end
@@ -109,7 +109,9 @@ describe PinboardApi::Tag do
109
109
  it "raises an exception" do
110
110
  Faraday::Response.any_instance.stubs(:body).returns("")
111
111
  VCR.use_cassette("tags/destroy/unsuccessful_class") do
112
- -> { PinboardApi::Tag.destroy("xxINVALIDxxBOGUSxx") }.must_raise(RuntimeError)
112
+ -> {
113
+ PinboardApi::Tag.destroy("xxINVALIDxxBOGUSxx")
114
+ }.must_raise(PinboardApi::InvalidResponseError)
113
115
  end
114
116
  end
115
117
  end