dropio 0.9.1 → 1.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.
data/lib/dropio.rb CHANGED
@@ -1,35 +1,34 @@
1
1
  module Dropio
2
- VERSION = '0.9.1'
2
+ VERSION = '1.0.0'
3
3
 
4
4
  class MissingResourceError < Exception; end
5
5
  class AuthorizationError < Exception; end
6
6
  class RequestError < Exception; end
7
7
  class ServerError < Exception; end
8
-
9
- class << self
10
- attr_accessor :api_key, :base_url, :api_url, :upload_url
8
+
9
+ class Config
10
+ class << self
11
+ attr_accessor :api_key, :base_url, :api_url, :upload_url, :version
12
+ end
11
13
  end
14
+
12
15
  end
13
16
 
14
-
15
- Dropio.base_url = "http://drop.io"
16
- Dropio.api_url = "http://api.drop.io"
17
- Dropio.upload_url = "http://assets.drop.io/upload"
18
-
19
- require 'net/http'
20
- require 'uri'
21
- require 'singleton'
22
17
  require 'rubygems'
18
+ require 'rbconfig'
23
19
  require 'mime/types'
24
- require 'base64'
25
- require 'cgi'
26
- require 'json'
27
- require 'digest/sha1'
20
+ require 'httparty'
21
+ require 'net/http/post/multipart'
22
+
23
+ Dropio::Config.base_url = "http://drop.io"
24
+ Dropio::Config.api_url = "http://api.drop.io"
25
+ Dropio::Config.upload_url = "http://assets.drop.io/upload"
26
+ Dropio::Config.version = "2.0"
28
27
 
28
+ require 'dropio/api'
29
29
  require 'dropio/client'
30
- require 'dropio/client/mapper'
31
- require 'dropio/client/multipart_post'
32
30
  require 'dropio/resource'
33
31
  require 'dropio/drop'
34
32
  require 'dropio/asset'
35
33
  require 'dropio/comment'
34
+ require 'dropio/subscription'
File without changes
@@ -1,39 +1,55 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe Asset do
3
+ describe Dropio::Asset do
4
4
  before(:each) do
5
- @asset = Asset.new
6
- @client = stub(Client)
7
- Client.stub!(:instance).and_return(@client)
5
+ @drop = Dropio::Drop.new
6
+ @drop.name = "test_drop"
7
+ @asset = Dropio::Asset.new
8
+ @asset.name = "test_asset"
9
+ @asset.drop = @drop
10
+
11
+ @client = Dropio::Client.new
12
+ @api = stub(Dropio::Api)
13
+ @client.service = @api
14
+
15
+ Dropio::Resource.stub!(:client).and_return(@client)
16
+ Dropio::Resource.client.should == @client
17
+ Dropio::Resource.client.service.should == @api
8
18
  end
9
19
 
10
20
  it "should have the attributes of an Asset" do
11
- @asset.should respond_to(:name, :type, :title, :description, :filesize,
12
- :created_at, :thumbnail, :status, :file,
13
- :converted, :hidden_url, :pages, :duration,
14
- :artist, :track_title, :height, :width,
15
- :contents, :url)
21
+ @asset.should respond_to(:drop, :name, :type, :title, :description, :filesize, :created_at,
22
+ :thumbnail, :status, :converted, :hidden_url, :pages, :fax_status,
23
+ :duration, :artist, :track_title, :height, :width, :contents, :url)
16
24
  end
17
25
 
18
26
  it "should have comments" do
19
27
  @comment = stub(Comment)
20
- @client.stub!(:find_comments).with(@asset).and_return([@comment])
28
+ @comment.should_receive(:asset=).once
29
+ @client.should_receive(:handle).with(:comments,{}).and_return([@comment])
30
+ @api.stub!(:comments).with(@drop.name, @asset.name, @drop.default_token).and_return({})
21
31
  @asset.comments.should == [@comment]
22
32
  end
23
33
 
24
34
  it "should create comments" do
25
35
  @comment = stub(Comment)
26
- @client.should_receive(:create_comment).with(@asset, "Totally rad asset, bro!").and_return(@comment)
36
+ @comment.should_receive(:asset=).once
37
+ @client.should_receive(:handle).with(:comment,{}).and_return(@comment)
38
+ @api.stub!(:create_comment).with(@drop.name, @asset.name, "Totally rad asset, bro!",@drop.default_token).and_return({})
27
39
  @asset.create_comment("Totally rad asset, bro!").should == @comment
28
40
  end
29
41
 
30
42
  it "should save itself" do
31
- @client.should_receive(:save_asset).with(@asset)
43
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
44
+ expected_hash = {:url=> "http://drop.io", :contents=>nil, :description=>nil, :title=>nil}
45
+ @asset.url = expected_hash[:url]
46
+ @api.stub!(:update_asset).with(@drop.name, @asset.name, expected_hash,@drop.default_token).and_return({})
32
47
  @asset.save
33
48
  end
34
49
 
35
50
  it "should destroy itself" do
36
- @client.should_receive(:destroy_asset).with(@asset)
51
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
52
+ @api.stub!(:delete_asset).with(@drop.name, @asset.name,@drop.default_token).and_return({})
37
53
  @asset.destroy!
38
54
  end
39
55
 
@@ -46,14 +62,72 @@ describe Asset do
46
62
 
47
63
  it "should fax itself to a phone number" do
48
64
  @asset.type = "Document"
49
- @client.should_receive(:send_to_fax).with(@asset,"234-567-8901")
65
+
66
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
67
+ @api.stub!(:send_asset_to_fax).with(@drop.name, @asset.name,"234-567-8901",@drop.default_token).and_return({})
50
68
  @asset.send_to_fax("234-567-8901")
51
69
  end
52
70
 
71
+ it "should email itself to a comma separated list of emails with an optional message" do
72
+ @asset.type = "Document"
73
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
74
+ @api.stub!(:send_asset_to_emails).with(@drop.name, @asset.name,"jake@dropio.com, jacob@dropio.com", "Awesome stuff!", @drop.default_token).and_return({})
75
+ @asset.send_to_emails("jake@dropio.com, jacob@dropio.com","Awesome stuff!")
76
+
77
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
78
+ @api.stub!(:send_asset_to_emails).with(@drop.name, @asset.name,"jake@dropio.com, jacob@dropio.com", nil, @drop.default_token).and_return({})
79
+ @asset.send_to_emails("jake@dropio.com, jacob@dropio.com")
80
+ end
81
+
82
+ it "should send itself to another drop." do
83
+ @target_drop = Drop.new
84
+ @target_drop.name = "target_drop"
85
+ @target_drop.guest_token = "guest_token"
86
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
87
+ @api.stub!(:send_asset_to_drop).with(@drop.name, @asset.name, @target_drop.name, @target_drop.guest_token, @drop.default_token).and_return({})
88
+ @asset.send_to_drop(@target_drop)
89
+ end
90
+
91
+ it "should copy itself to another drop." do
92
+ @target_drop = Drop.new
93
+ @target_drop.name = "target_drop"
94
+ @target_drop.guest_token = "guest_token"
95
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
96
+ @api.stub!(:copy_asset).with(@drop.name, @asset.name, @target_drop.name, @target_drop.guest_token, @drop.default_token).and_return({})
97
+ @asset.copy_to(@target_drop)
98
+ end
99
+
100
+ it "should move itself to another drop." do
101
+ @target_drop = Drop.new
102
+ @target_drop.name = "target_drop"
103
+ @target_drop.guest_token = "guest_token"
104
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
105
+ @api.stub!(:move_asset).with(@drop.name, @asset.name, @target_drop.name, @target_drop.guest_token, @drop.default_token).and_return({})
106
+ @asset.move_to(@target_drop)
107
+ end
108
+
53
109
  it "should not fax itself if it's not faxable" do
54
110
  @asset.type = "Video"
55
- @client.should_not_receive(:send_to_fax)
111
+ @api.should_not_receive(:send_asset_to_fax)
56
112
  # TODO: Make this a specific error.
57
113
  lambda { @asset.send_to_fax("234-567-8901") }.should raise_error
58
114
  end
59
- end
115
+
116
+ it "should find itself" do
117
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
118
+ @api.should_receive(:asset).with(@drop.name, @asset.name, @drop.default_token).and_return({})
119
+ Asset.find(@drop,@asset.name).should == @asset
120
+ end
121
+
122
+ it "should generate a signed url" do
123
+ @api.should_receive(:generate_drop_url).with(@drop.name,@asset.name,@drop.default_token)
124
+ @asset.generate_url
125
+ end
126
+
127
+ it "should get it's embed_code" do
128
+ @client.should_receive(:handle).with(:response,{}).and_return({"response" => {"embed_code" => "my_embed_code"}})
129
+ @api.should_receive(:asset_embed_code).with(@drop.name,@asset.name,@drop.default_token).and_return({})
130
+ @asset.embed_code
131
+ end
132
+
133
+ end
@@ -1,322 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Client do
4
- def mock_http(method, path, response, form_data = nil)
5
- request_klass = { :get => Net::HTTP::Get,
6
- :post => Net::HTTP::Post,
7
- :put => Net::HTTP::Put,
8
- :delete => Net::HTTP::Delete }[method]
9
- raise "Don't know how to mock a #{method.inspect} HTTP call." if request_klass.nil?
10
- request = mock(request_klass)
11
- request.should_receive(:set_form_data).with(form_data) if form_data
12
- request_klass.stub!(:new).with(path, Client::DEFAULT_HEADER).and_return(request)
13
-
14
- http = mock(Net::HTTP)
15
- Net::HTTP.stub!(:new).with("api.drop.io").and_return(http)
16
- http.stub!(:start).and_yield(http)
17
- http.stub!(:request).with(request).and_return(response)
18
- end
19
-
20
- def stub_asset(more_stubs={})
21
- stub Asset, [:drop, :name, :type, :title, :description, :filesize, :created_at,
22
- :thumbnail, :status, :file, :converted, :hidden_url, :pages,
23
- :duration, :artist, :track_title, :height, :width, :contents, :url].
24
- inject({}) { |stubs, key| stubs[key] = nil; stubs }.merge(more_stubs)
25
- end
26
-
27
- before(:each) do
28
- # Don't allow HTTPRequests to be created without being
29
- # specifically stubbed, typically with mock_http above.
30
- [Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete].each do |request_klass|
31
- request_klass.stub!(:new).with do |*args|
32
- raise "Created an unexpected #{request_klass}!\n#{request_klass}.new(#{args.map { |e| e.inspect }.join(", ")})"
33
- end
34
- end
35
-
36
- Dropio.api_url = "http://api.drop.io"
37
- Dropio.api_key = "43myapikey13"
38
-
39
- @api_response_body = stub("API Response Body")
40
- @api_response = stub(Net::HTTPSuccess, :body => @api_response_body)
41
-
42
- @mydrop = stub(Drop, :name => 'mydrop', :admin_token => '93mydroptoken97')
43
- @note = stub_asset(:drop => @mydrop, :name => 'a-note', :contents => "My thoughts on life.")
44
- @link = stub_asset(:drop => @mydrop, :name => 'a-link', :url => "http://google.com/")
45
- @file_asset = stub_asset(:drop => @mydrop, :name => 'some-video')
46
- @comment = stub(Comment, :asset => @file_asset, :id => 1, :contents => "I remember that day.")
47
- end
48
-
49
- it "should create drops" do
50
- settings = {:name => "mynewdrop",
51
- :admin_password => "niftieradminpassword",
52
- :password => "niftyguestpassword",
53
- :guests_can_comment => true,
54
- :guests_can_add => true,
55
- :guests_can_delete => false,
56
- :expiration_length => "1_WEEK_FROM_NOW",
57
- :premium_code => "yeswecan"}
58
-
59
- mock_http(:post, "/drops/", @api_response, settings.merge(:api_key => "43myapikey13", :format => "json", :version => "1.0"))
60
- Client::Mapper.stub!(:map_drops).with(@api_response_body).and_return(@mydrop)
61
- Client.instance.create_drop(settings).should == @mydrop
62
- end
63
-
64
- it "should create notes" do
65
- mock_http(:post, "/drops/mydrop/assets/", @api_response, :title => "Just a Note",
66
- :contents => "This is just to say",
67
- :token => "93mydroptoken97",
68
- :api_key => "43myapikey13",
69
- :format => "json",
70
- :version => "1.0")
71
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(@note)
72
- Client.instance.create_note(@mydrop, "Just a Note", "This is just to say").should == @note
73
- end
74
-
75
- it "should create links" do
76
- mock_http(:post, "/drops/mydrop/assets/", @api_response, :url => "http://drop.io/",
77
- :title => "Drop.io",
78
- :description => "An awesome sharing site.",
79
- :token => "93mydroptoken97",
80
- :api_key => "43myapikey13",
81
- :format => "json",
82
- :version => "1.0")
83
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(@link)
84
- Client.instance.create_link(@mydrop, "http://drop.io/", "Drop.io", "An awesome sharing site.").should == @link
85
- end
86
-
87
- it "should add files" do
88
- file = stub(File)
89
- File.stub!(:open).with("/path/to/video.avi", "r").and_yield(file)
90
-
91
- path = "/upload"
92
- form_data = {:drop_name => "mydrop",
93
- :file => file,
94
- :token => "93mydroptoken97",
95
- :api_key => "43myapikey13",
96
- :format => "json",
97
- :version => "1.0"}
98
-
99
- # We can't use mock_http here because the host is different and we're using multipart.
100
- request = mock(Net::HTTP::Post)
101
- request.should_receive(:multipart_params=).with(form_data) if form_data
102
- Net::HTTP::Post.stub!(:new).with(path, Client::DEFAULT_HEADER).and_return(request)
103
-
104
- http = mock(Net::HTTP)
105
- Net::HTTP.stub!(:new).with("assets.drop.io").and_return(http)
106
- http.stub!(:start).and_yield(http)
107
- http.stub!(:request).with(request).and_return(@api_response)
108
-
109
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(@file_asset)
110
- Client.instance.add_file(@mydrop, "/path/to/video.avi").should == @file_asset
111
- end
112
-
113
- it "should create comments" do
114
- comment = stub(Comment)
115
- mock_http(:post, "/drops/mydrop/assets/some-video/comments/", @api_response,
116
- :contents => "What a cool video!",
117
- :token => "93mydroptoken97",
118
- :api_key => "43myapikey13",
119
- :format => "json",
120
- :version => "1.0")
121
- Client::Mapper.stub!(:map_comments).with(@file_asset, @api_response_body).and_return(comment)
122
- Client.instance.create_comment(@file_asset, "What a cool video!").should == comment
123
- end
124
-
125
- it "should find drops" do
126
- mock_http(:get, "/drops/mydrop?api_key=43myapikey13&token=93mydroptoken97&version=1.0&format=json", @api_response)
127
- Client::Mapper.stub!(:map_drops).with(@api_response_body).and_return(@mydrop)
128
- Client.instance.find_drop("mydrop", "93mydroptoken97").should == @mydrop
129
- end
130
-
131
- it "should find assets" do
132
- mock_http(:get, %r|^/drops/mydrop/assets/\?api_key=43myapikey13&token=93mydroptoken97&version=1.0&format=json|, @api_response)
133
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return([@file_asset])
134
- Client.instance.find_assets(@mydrop).should == [@file_asset]
135
- end
136
-
137
- it "should find comments" do
138
- mock_http(:get, %r|^/drops/mydrop/assets/some-video/comments/\?api_key=43myapikey13&token=93mydroptoken97&version=1.0&format=json|, @api_response)
139
- Client::Mapper.stub!(:map_comments).with(@file_asset, @api_response_body).and_return([@comment])
140
- Client.instance.find_comments(@file_asset).should == [@comment]
141
- end
142
-
143
- it "should save drops" do
144
- @mydrop.stub!(:guests_can_comment => true,
145
- :guests_can_add => false,
146
- :guests_can_delete => false,
147
- :expiration_length => "1_WEEK_FROM_LAST_VIEW",
148
- :password => "mazda",
149
- :admin_password => "foo64bar",
150
- :premium_code => "yeswecan")
151
-
152
- mock_http(:put, "/drops/mydrop", @api_response,
153
- :guests_can_comment => true,
154
- :guests_can_add => false,
155
- :guests_can_delete => false,
156
- :expiration_length => "1_WEEK_FROM_LAST_VIEW",
157
- :password => "mazda",
158
- :admin_password => "foo64bar",
159
- :premium_code => "yeswecan",
160
- :token => "93mydroptoken97",
161
- :api_key => "43myapikey13",
162
- :format => "json",
163
- :version => "1.0")
164
-
165
- new_drop = stub(Drop)
166
- Client::Mapper.stub!(:map_drops).with(@api_response_body).and_return(new_drop)
167
- Client.instance.save_drop(@mydrop).should == new_drop
168
- end
169
-
170
- it "should save note assets" do
171
- @note.stub!(:title => "Just a Note",
172
- :contents => "This is just to say")
173
-
174
- mock_http(:put, "/drops/mydrop/assets/a-note", @api_response,
175
- :title => "Just a Note",
176
- :description => nil,
177
- :url => nil,
178
- :contents => "This is just to say",
179
- :token => "93mydroptoken97",
180
- :api_key => "43myapikey13",
181
- :format => "json",
182
- :version => "1.0")
183
-
184
- new_note = stub_asset
185
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(new_note)
186
- Client.instance.save_asset(@note).should == new_note
187
- end
188
-
189
- it "should save link assets" do
190
- @link.stub!(:url => "http://drop.io/",
191
- :title => "Drop.io",
192
- :description => "An awesome sharing site.")
193
-
194
- mock_http(:put, "/drops/mydrop/assets/a-link", @api_response,
195
- :title => "Drop.io",
196
- :description => "An awesome sharing site.",
197
- :url => "http://drop.io/",
198
- :contents => nil,
199
- :token => "93mydroptoken97",
200
- :api_key => "43myapikey13",
201
- :format => "json",
202
- :version => "1.0")
203
-
204
- new_link = stub_asset
205
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(new_link)
206
- Client.instance.save_asset(@link).should == new_link
207
- end
208
-
209
- it "should save file assets" do
210
- @file_asset.stub!(:title => "Snowboarding in March",
211
- :description => "This was really fun.")
212
-
213
- mock_http(:put, "/drops/mydrop/assets/some-video", @api_response,
214
- :title => "Snowboarding in March",
215
- :description => "This was really fun.",
216
- :url => nil,
217
- :contents => nil,
218
- :token => "93mydroptoken97",
219
- :api_key => "43myapikey13",
220
- :format => "json",
221
- :version => "1.0")
222
-
223
- new_file_asset = stub_asset
224
- Client::Mapper.stub!(:map_assets).with(@mydrop, @api_response_body).and_return(new_file_asset)
225
- Client.instance.save_asset(@file_asset).should == new_file_asset
226
- end
227
-
228
- it "should save comments" do
229
- @comment.stub!(:contents => "I remember that day.")
230
-
231
- mock_http(:put, "/drops/mydrop/assets/some-video/comments/1", @api_response,
232
- :contents => "I remember that day.",
233
- :token => "93mydroptoken97",
234
- :api_key => "43myapikey13",
235
- :format => "json",
236
- :version => "1.0")
237
-
238
- new_comment = stub(Comment)
239
-
240
- Client::Mapper.stub!(:map_comments).with(@file_asset, @api_response_body).and_return(new_comment)
241
- Client.instance.save_comment(@comment).should == new_comment
242
- end
243
-
244
- it "should destroy drops" do
245
- mock_http(:delete, "/drops/mydrop", @api_response, :token => "93mydroptoken97",
246
- :api_key => "43myapikey13",
247
- :format => "json",
248
- :version => "1.0")
249
-
250
- Client.instance.destroy_drop(@mydrop).should be_true
251
- end
252
-
253
- it "should destroy assets" do
254
- mock_http(:delete, "/drops/mydrop/assets/some-video", @api_response,
255
- :token => "93mydroptoken97",
256
- :api_key => "43myapikey13",
257
- :format => "json",
258
- :version => "1.0")
259
-
260
- Client.instance.destroy_asset(@file_asset).should be_true
261
- end
262
-
263
- it "should destroy comments" do
264
- mock_http(:delete, "/drops/mydrop/assets/some-video/comments/1", @api_response,
265
- :token => "93mydroptoken97",
266
- :api_key => "43myapikey13",
267
- :format => "json",
268
- :version => "1.0")
269
-
270
- Client.instance.destroy_comment(@comment).should be_true
271
- end
272
-
273
- it "should send assets by fax" do
274
- mock_http(:post, "/drops/mydrop/assets/some-video/send_to",
275
- @api_response,
276
- :medium => "fax",
277
- :fax_number => "12345678901",
278
- :token => "93mydroptoken97",
279
- :api_key => "43myapikey13",
280
- :format => "json",
281
- :version => "1.0")
282
-
283
- Client.instance.send_to_fax(@file_asset, "12345678901").should be_true
284
- end
285
-
286
- it "should send assets by email" do
287
- mock_http(:post, "/drops/mydrop/assets/some-video/send_to",
288
- @api_response,
289
- :medium => "email",
290
- :emails => "joe@broomtown.com,bill@vaccsrus.com",
291
- :message => "Check this out!",
292
- :token => "93mydroptoken97",
293
- :api_key => "43myapikey13",
294
- :format => "json",
295
- :version => "1.0")
296
-
297
- Client.instance.send_to_emails(@file_asset,
298
- ["joe@broomtown.com", "bill@vaccsrus.com"],
299
- "Check this out!").should be_true
300
- end
301
-
302
- it "should send assets to drops" do
303
- mock_http(:post, "/drops/mydrop/assets/some-video/send_to",
304
- @api_response,
305
- :medium => "drop",
306
- :drop_name => "myotherdrop",
307
- :token => "93mydroptoken97",
308
- :api_key => "43myapikey13",
309
- :format => "json",
310
- :version => "1.0")
311
-
312
- Client.instance.send_to_drop(@file_asset, "myotherdrop").should be_true
313
- end
314
-
315
- it "should generate drop urls" do
316
- Client.instance.generate_drop_url(@mydrop).should =~ %r|http://drop.io/mydrop/from_api\?expires=\d+&signature=[0-9a-f]+|
317
- end
318
-
319
- it "should generate asset urls" do
320
- Client.instance.generate_asset_url(@file_asset).should =~ %r|http://drop.io/mydrop/asset/some-video/from_api\?expires=\d+&signature=[0-9a-f]+|
321
- end
322
- end
@@ -1,10 +1,22 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe Comment do
3
+ describe Dropio::Comment do
4
4
  before(:each) do
5
- @comment = Comment.new
6
- @client = stub(Client)
7
- Client.stub!(:instance).and_return(@client)
5
+ @drop = Dropio::Drop.new
6
+ @drop.name = "test_drop"
7
+ @asset = Dropio::Asset.new
8
+ @asset.drop = @drop
9
+ @asset.name = "test_asset"
10
+ @comment = Dropio::Comment.new
11
+ @comment.asset = @asset
12
+
13
+ @client = Dropio::Client.new
14
+ @api = stub(Dropio::Api)
15
+ @client.service = @api
16
+
17
+ Dropio::Resource.stub!(:client).and_return(@client)
18
+ Dropio::Resource.client.should == @client
19
+ Dropio::Resource.client.service.should == @api
8
20
  end
9
21
 
10
22
  it "should have the attributes of an Comment" do
@@ -12,12 +24,15 @@ describe Comment do
12
24
  end
13
25
 
14
26
  it "should save itself" do
15
- @client.should_receive(:save_comment).with(@comment)
27
+ @client.should_receive(:handle).with(:comment,{}).and_return(@comment)
28
+ @api.should_receive(:update_comment).with(@drop.name, @asset.name, @comment.id, "My new content", @drop.default_token).and_return({})
29
+ @comment.contents = "My new content"
16
30
  @comment.save
17
31
  end
18
32
 
19
33
  it "should destroy itself" do
20
- @client.should_receive(:destroy_comment).with(@comment)
21
- @comment.destroy
34
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
35
+ @api.should_receive(:delete_comment).with(@drop.name, @asset.name, @comment.id, @drop.admin_token).and_return({})
36
+ @comment.destroy!
22
37
  end
23
38
  end