cloudapp 2.0.0.beta.4 → 2.0.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +12 -19
- data/README.md +60 -6
- data/Rakefile +1 -19
- data/bin/cloudapp +48 -0
- data/cloudapp.gemspec +11 -42
- data/lib/cloudapp/authorized.rb +14 -0
- data/lib/cloudapp/collection_json.rb +86 -3
- data/lib/cloudapp/credentials.rb +115 -0
- data/lib/cloudapp/service.rb +43 -146
- data/lib/cloudapp.rb +1 -3
- data/man/cloudapp.1 +100 -0
- data/man/cloudapp.1.html +157 -0
- data/man/cloudapp.1.ronn +56 -0
- metadata +24 -69
- data/CHANGELOG.md +0 -34
- data/lib/cloudapp/authorized_representation.rb +0 -17
- data/lib/cloudapp/collection_json/item.rb +0 -20
- data/lib/cloudapp/collection_json/representation.rb +0 -74
- data/lib/cloudapp/collection_json/template.rb +0 -17
- data/lib/cloudapp/collection_json/tint.rb +0 -11
- data/lib/cloudapp/drop.rb +0 -37
- data/lib/cloudapp/drop_collection.rb +0 -37
- data/spec/cassettes/account_token.yml +0 -88
- data/spec/cassettes/create_bookmark.yml +0 -132
- data/spec/cassettes/create_bookmark_with_name.yml +0 -133
- data/spec/cassettes/create_bookmark_with_privacy.yml +0 -133
- data/spec/cassettes/list_drops.yml +0 -87
- data/spec/cassettes/list_drops_with_bad_token.yml +0 -45
- data/spec/cassettes/list_drops_with_filter.yml +0 -129
- data/spec/cassettes/list_drops_with_limit.yml +0 -129
- data/spec/cassettes/purge_drops.yml +0 -466
- data/spec/cassettes/setup_drops.yml +0 -620
- data/spec/cassettes/token_for_account.yml +0 -88
- data/spec/cassettes/token_for_account_with_bad_credentials.yml +0 -86
- data/spec/cassettes/upload_file.yml +0 -276
- data/spec/cassettes/upload_file_with_name.yml +0 -278
- data/spec/cassettes/upload_file_with_privacy.yml +0 -277
- data/spec/cassettes/view_drop.yml +0 -45
- data/spec/cloudapp/authorized_representation_spec.rb +0 -32
- data/spec/cloudapp/collection_json/item_spec.rb +0 -45
- data/spec/cloudapp/collection_json/representation_spec.rb +0 -118
- data/spec/cloudapp/collection_json/template_spec.rb +0 -53
- data/spec/cloudapp/drop_collection_spec.rb +0 -127
- data/spec/cloudapp/drop_spec.rb +0 -142
- data/spec/cloudapp/service_spec.rb +0 -335
- data/spec/helper.rb +0 -8
- data/spec/integration_spec.rb +0 -68
- data/spec/support/files/favicon.ico +0 -0
- data/spec/support/stub_class_or_module.rb +0 -22
- data/spec/support/vcr.rb +0 -24
@@ -1,335 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'support/vcr'
|
3
|
-
|
4
|
-
require 'cloudapp/service'
|
5
|
-
|
6
|
-
describe CloudApp::Service do
|
7
|
-
let(:service) { CloudApp::Service.using_token token }
|
8
|
-
let(:token) { 'abc123' }
|
9
|
-
let(:email) { 'arthur@dent.com' }
|
10
|
-
let(:password) { 'towel' }
|
11
|
-
let(:favicon) {
|
12
|
-
Pathname('../../support/files/favicon.ico').expand_path(__FILE__)
|
13
|
-
}
|
14
|
-
|
15
|
-
after(:all) do
|
16
|
-
VCR.use_cassette('purge_drops') do
|
17
|
-
service.drops(filter: 'all').each do |drop|
|
18
|
-
service.delete_drop(drop.href)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '.token_for_account' do
|
24
|
-
subject {
|
25
|
-
VCR.use_cassette('token_for_account') {
|
26
|
-
CloudApp::Service.token_for_account email, password
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
it 'returns the token' do
|
31
|
-
subject.should be_a(String)
|
32
|
-
subject.should eq(token)
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'with bad credentials' do
|
36
|
-
let(:password) { 'wrong' }
|
37
|
-
subject {
|
38
|
-
VCR.use_cassette('token_for_account_with_bad_credentials') {
|
39
|
-
CloudApp::Service.token_for_account email, password
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
it 'returns nothing' do
|
44
|
-
subject.should be_nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#account_token' do
|
50
|
-
subject {
|
51
|
-
VCR.use_cassette('account_token') {
|
52
|
-
CloudApp::Service.new.account_token email, password
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
it { should be_a(CloudApp::CollectionJson::Representation) }
|
57
|
-
|
58
|
-
it 'returns a single item' do
|
59
|
-
subject.should have(1).item
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'returns the token' do
|
63
|
-
subject.items.first.data.should eq('token' => token)
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'with bad credentials' do
|
67
|
-
let(:password) { 'wrong' }
|
68
|
-
subject {
|
69
|
-
VCR.use_cassette('token_for_account_with_bad_credentials') {
|
70
|
-
CloudApp::Service.new.account_token email, password
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
it { should be_unauthorized }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#drops' do
|
79
|
-
subject { VCR.use_cassette('list_drops') { service.drops }}
|
80
|
-
before do
|
81
|
-
VCR.use_cassette('setup_drops') do
|
82
|
-
service.upload favicon
|
83
|
-
service.bookmark 'http://cl.ly', private: false
|
84
|
-
drop = service.bookmark('http://getcloudapp.com', name: 'CloudApp').first
|
85
|
-
service.trash_drop drop.href
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it { should be_a(CloudApp::DropCollection) }
|
90
|
-
|
91
|
-
it 'has 2 drops' do
|
92
|
-
subject.should have(2).items
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'with filter' do
|
96
|
-
subject {
|
97
|
-
VCR.use_cassette('list_drops_with_filter') {
|
98
|
-
service.drops filter: 'trash'
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
it { should be_a(CloudApp::DropCollection) }
|
103
|
-
|
104
|
-
it 'returns the filtered drops' do
|
105
|
-
subject.should have(1).items
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'with limit' do
|
110
|
-
subject {
|
111
|
-
VCR.use_cassette('list_drops_with_limit') {
|
112
|
-
service.drops limit: 1
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
it { should be_a(CloudApp::DropCollection) }
|
117
|
-
|
118
|
-
it 'limits drops' do
|
119
|
-
subject.should have(1).items
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'with a bad token' do
|
124
|
-
let(:token) { 'wrong' }
|
125
|
-
subject {
|
126
|
-
VCR.use_cassette('list_drops_with_bad_token') {
|
127
|
-
service.drops
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
it { should be_a(CloudApp::DropCollection) }
|
132
|
-
it { should be_unauthorized }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe '#drop' do
|
137
|
-
subject {
|
138
|
-
VCR.use_cassette('list_drops') {
|
139
|
-
@href = service.drops.first.href
|
140
|
-
}
|
141
|
-
VCR.use_cassette('view_drop') { service.drop(@href) }
|
142
|
-
}
|
143
|
-
|
144
|
-
it { should be_a(CloudApp::DropCollection) }
|
145
|
-
|
146
|
-
it 'returns a drop' do
|
147
|
-
subject.should have(1).item
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe '#bookmark' do
|
152
|
-
let(:url) { 'http://getcloudapp.com' }
|
153
|
-
subject {
|
154
|
-
VCR.use_cassette('create_bookmark') { service.bookmark(url) }
|
155
|
-
}
|
156
|
-
|
157
|
-
it { should be_a(CloudApp::DropCollection) }
|
158
|
-
|
159
|
-
it 'returns the new drop' do
|
160
|
-
subject.should have(1).item
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'with a name' do
|
164
|
-
let(:name) { 'New Bookmark' }
|
165
|
-
subject {
|
166
|
-
VCR.use_cassette('create_bookmark_with_name') {
|
167
|
-
service.bookmark url, name: name
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
it 'has the given name' do
|
172
|
-
subject.first.data['name'].should eq(name)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
context 'with a privacy' do
|
177
|
-
subject {
|
178
|
-
VCR.use_cassette('create_bookmark_with_privacy') {
|
179
|
-
service.bookmark url, private: false
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
it 'is public' do
|
184
|
-
subject.first.data['private'].should eq(false)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe '#upload' do
|
190
|
-
subject {
|
191
|
-
VCR.use_cassette('upload_file') { service.upload(favicon) }
|
192
|
-
}
|
193
|
-
|
194
|
-
it { should be_a(CloudApp::DropCollection) }
|
195
|
-
|
196
|
-
it 'returns the new drop' do
|
197
|
-
subject.should have(1).item
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'with a name' do
|
201
|
-
let(:name) { 'New File' }
|
202
|
-
subject {
|
203
|
-
VCR.use_cassette('upload_file_with_name') {
|
204
|
-
service.upload favicon, name: name
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
it 'has the given name' do
|
209
|
-
subject.first.data['name'].should eq(name)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context 'with a privacy' do
|
214
|
-
subject {
|
215
|
-
VCR.use_cassette('upload_file_with_privacy') {
|
216
|
-
service.upload favicon, private: false
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
it 'is public' do
|
221
|
-
subject.first.data['private'].should eq(false)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
describe 'too large file'
|
226
|
-
end
|
227
|
-
|
228
|
-
|
229
|
-
# describe '#update' do
|
230
|
-
# let(:url) { 'http://getcloudapp.com' }
|
231
|
-
# let(:name) { 'New Drop Name' }
|
232
|
-
# let(:private) { false }
|
233
|
-
# subject {
|
234
|
-
# VCR.use_cassette('rename_drop') {
|
235
|
-
# drop = service.bookmark(url).items.first
|
236
|
-
# service.update drop.href, name: name, private: private
|
237
|
-
# }
|
238
|
-
# }
|
239
|
-
|
240
|
-
# it { should be_a(CloudApp::CollectionJson::Representation) }
|
241
|
-
|
242
|
-
# it 'returns the updated drop' do
|
243
|
-
# subject.should have(1).item
|
244
|
-
# end
|
245
|
-
|
246
|
-
# it 'updates the name' do
|
247
|
-
# subject.items.first.data['name'].should eq(name)
|
248
|
-
# end
|
249
|
-
|
250
|
-
# it 'updates the privacy' do
|
251
|
-
# subject.items.first.data['private'].should eq(private)
|
252
|
-
# end
|
253
|
-
|
254
|
-
# context 'updating bookmark link' do
|
255
|
-
# subject {
|
256
|
-
# VCR.use_cassette('update_drop_bookmark_url') {
|
257
|
-
# drop = service.bookmark(url).items.first
|
258
|
-
# service.update drop.href, url: 'http://example.org'
|
259
|
-
# }
|
260
|
-
# }
|
261
|
-
|
262
|
-
# it { should be_a(CloudApp::CollectionJson::Representation) }
|
263
|
-
|
264
|
-
# it 'returns the new drop' do
|
265
|
-
# subject.should have(1).item
|
266
|
-
# end
|
267
|
-
# end
|
268
|
-
|
269
|
-
# context 'updating file' do
|
270
|
-
# let(:options) {{ path: favicon }}
|
271
|
-
# subject {
|
272
|
-
# VCR.use_cassette('update_file') {
|
273
|
-
# drop = service.bookmark(url).items.first
|
274
|
-
# service.update drop.href, options
|
275
|
-
# }
|
276
|
-
# }
|
277
|
-
|
278
|
-
# it { should be_a(CloudApp::CollectionJson::Representation) }
|
279
|
-
|
280
|
-
# it 'returns the new drop' do
|
281
|
-
# subject.should have(1).item
|
282
|
-
# end
|
283
|
-
# end
|
284
|
-
# end
|
285
|
-
|
286
|
-
# describe '#trash_drop' do
|
287
|
-
# subject {
|
288
|
-
# VCR.use_cassette('trash_drop') {
|
289
|
-
# drop = service.bookmark('http://getcloudapp.com').items.first
|
290
|
-
# service.trash_drop drop.href
|
291
|
-
# }
|
292
|
-
# }
|
293
|
-
|
294
|
-
# it { should be_a(CloudApp::CollectionJson::Representation) }
|
295
|
-
|
296
|
-
# it 'returns the trashed drop' do
|
297
|
-
# subject.should have(1).item
|
298
|
-
# end
|
299
|
-
|
300
|
-
# it 'trashes the drop' do
|
301
|
-
# subject.items.first.data['trash'].should eq(true)
|
302
|
-
# end
|
303
|
-
# end
|
304
|
-
|
305
|
-
# describe '#recover_drop' do
|
306
|
-
# subject {
|
307
|
-
# VCR.use_cassette('recover_drop') {
|
308
|
-
# drop = service.bookmark('http://getcloudapp.com').items.first
|
309
|
-
# service.trash_drop drop.href
|
310
|
-
# service.recover_drop drop.href
|
311
|
-
# }
|
312
|
-
# }
|
313
|
-
|
314
|
-
# it { should be_a(CloudApp::CollectionJson::Representation) }
|
315
|
-
|
316
|
-
# it 'returns the recovered drop' do
|
317
|
-
# subject.should have(1).item
|
318
|
-
# end
|
319
|
-
|
320
|
-
# it 'recovers the drop' do
|
321
|
-
# subject.items.first.data['trash'].should eq(false)
|
322
|
-
# end
|
323
|
-
# end
|
324
|
-
|
325
|
-
# describe '#delete_drop' do
|
326
|
-
# subject {
|
327
|
-
# VCR.use_cassette('delete_drop') {
|
328
|
-
# drop = service.bookmark('http://getcloudapp.com').items.first
|
329
|
-
# service.delete_drop drop.href
|
330
|
-
# }
|
331
|
-
# }
|
332
|
-
|
333
|
-
# it { should be_authorized }
|
334
|
-
# end
|
335
|
-
end
|
data/spec/helper.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'support/stub_class_or_module'
|
2
|
-
require 'English'
|
3
|
-
|
4
|
-
root = File.expand_path('../..', __FILE__)
|
5
|
-
$LOAD_PATH.unshift(File.expand_path('app/models', root))
|
6
|
-
$LOAD_PATH.unshift(File.expand_path('app/controllers', root))
|
7
|
-
$LOAD_PATH.unshift(File.expand_path('app/helpers', root))
|
8
|
-
$LOAD_PATH.unshift(File.expand_path('lib', root))
|
data/spec/integration_spec.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'support/vcr'
|
3
|
-
|
4
|
-
require 'cloudapp'
|
5
|
-
|
6
|
-
describe CloudApp, :integration do
|
7
|
-
let(:path) { Pathname('../support/files/favicon.ico').expand_path(__FILE__) }
|
8
|
-
|
9
|
-
it 'integrates with the API' do
|
10
|
-
token = CloudApp::Service.token_for_account 'arthur@dent.com', 'towel'
|
11
|
-
token.should =~ /\w+/
|
12
|
-
|
13
|
-
service = CloudApp::Service.using_token token
|
14
|
-
service.drops(filter: 'all').each(&:delete)
|
15
|
-
service.drops(filter: 'all').should be_empty
|
16
|
-
|
17
|
-
bookmark = service.bookmark('http://getcloudapp.com', name: 'CloudApp').first
|
18
|
-
file = service.upload(path).first
|
19
|
-
public_drop = service.bookmark('http://getcloudapp.com', private: false).first
|
20
|
-
|
21
|
-
service.drops(filter: 'all').should have(3).items
|
22
|
-
|
23
|
-
bookmark_details = service.drop(bookmark.href).first
|
24
|
-
bookmark_details.name .should eq('CloudApp')
|
25
|
-
bookmark_details.private.should eq(true)
|
26
|
-
|
27
|
-
file_details = service.drop(file.href).first
|
28
|
-
file_details.name .should eq('favicon.ico')
|
29
|
-
file_details.private.should eq(true)
|
30
|
-
|
31
|
-
public_drop_details = service.drop(public_drop.href).first
|
32
|
-
public_drop_details.name .should eq('http://getcloudapp.com')
|
33
|
-
public_drop_details.private.should eq(false)
|
34
|
-
|
35
|
-
bookmark.trash
|
36
|
-
file .trash
|
37
|
-
service.drops(filter: 'all') .should have(3).items
|
38
|
-
service.drops(filter: 'active').should have(1).item
|
39
|
-
service.drops(filter: 'trash') .should have(2).items
|
40
|
-
|
41
|
-
bookmark.recover
|
42
|
-
service.drops(filter: 'all') .should have(3).items
|
43
|
-
service.drops(filter: 'active').should have(2).item
|
44
|
-
service.drops(filter: 'trash') .should have(1).items
|
45
|
-
|
46
|
-
page1 = service.drops(filter: 'all', limit: 1)
|
47
|
-
page1.should have(1).item
|
48
|
-
|
49
|
-
page2 = page1.follow 'next'
|
50
|
-
page2.should have(1).item
|
51
|
-
|
52
|
-
page3 = page2.follow 'next'
|
53
|
-
page3.should have(1).item
|
54
|
-
page3.has_link?('next').should eq(false)
|
55
|
-
|
56
|
-
page2 = page3.follow 'previous'
|
57
|
-
page2.should have(1).item
|
58
|
-
|
59
|
-
page1 = page2.follow 'previous'
|
60
|
-
page1.should have(1).item
|
61
|
-
page1.has_link?('previous').should eq(false)
|
62
|
-
|
63
|
-
bookmark .delete
|
64
|
-
file .delete
|
65
|
-
public_drop.delete
|
66
|
-
service.drops(filter: 'all').should be_empty
|
67
|
-
end
|
68
|
-
end
|
Binary file
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Stubbed end
|
2
|
-
|
3
|
-
def stub_module(full_name, &block)
|
4
|
-
stub_class_or_module full_name, Module, &block
|
5
|
-
end
|
6
|
-
|
7
|
-
def stub_class(full_name, &block)
|
8
|
-
stub_class_or_module full_name, Class, &block
|
9
|
-
end
|
10
|
-
|
11
|
-
def stub_class_or_module(full_name, kind, &block)
|
12
|
-
stub = full_name.to_s.split(/::/).inject(Object) do |context, name|
|
13
|
-
begin
|
14
|
-
context.const_get(name)
|
15
|
-
rescue NameError
|
16
|
-
stubbed = kind.new do include(Stubbed) end
|
17
|
-
context.const_set(name, stubbed)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
stub.class_eval &block if block
|
22
|
-
end
|
data/spec/support/vcr.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'vcr'
|
2
|
-
|
3
|
-
VCR.configure do |vcr|
|
4
|
-
vcr.cassette_library_dir = 'spec/cassettes'
|
5
|
-
vcr.default_cassette_options = { record: :once,
|
6
|
-
match_requests_on: [ :method, :uri, :body ]}
|
7
|
-
vcr.hook_into :webmock
|
8
|
-
vcr.configure_rspec_metadata!
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.configure do |rspec|
|
12
|
-
rspec.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
-
rspec.before :each, integration: true do
|
14
|
-
VCR.configure do |vcr|
|
15
|
-
vcr.allow_http_connections_when_no_cassette = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
rspec.after :each, integration: true do
|
20
|
-
VCR.configure do |vcr|
|
21
|
-
vcr.allow_http_connections_when_no_cassette = false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|