dropbox-api-petems 0.4.2 → 1.0.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.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/README.markdown +13 -8
- data/Rakefile +5 -0
- data/dropbox-api.gemspec +9 -8
- data/lib/dropbox-api.rb +1 -0
- data/lib/dropbox-api/objects/dir.rb +5 -0
- data/lib/dropbox-api/objects/file.rb +5 -10
- data/lib/dropbox-api/objects/fileops.rb +5 -0
- data/lib/dropbox-api/tasks.rb +2 -2
- data/lib/dropbox-api/version.rb +1 -1
- data/spec/connection.offline.yml +5 -0
- data/spec/lib/dropbox-api/client_spec.rb +96 -68
- data/spec/lib/dropbox-api/connection_spec.rb +1 -1
- data/spec/lib/dropbox-api/dir_spec.rb +12 -6
- data/spec/lib/dropbox-api/file_spec.rb +7 -11
- data/spec/lib/dropbox-api/oauth_spec.rb +22 -1
- data/spec/lib/dropbox-api/thumbnail_spec.rb +4 -4
- data/spec/spec_helper.rb +13 -4
- data/spec/support/config.rb +5 -1
- data/spec/vcr/cassettes/Dropbox_API_Client/_account/retrieves_the_account_object.yml +54 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_chunked_upload/puts_a_5MB_file_in_dropbox.yml +150 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_chunked_upload/yields_current_offset_and_upload_id.yml +150 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_copy_from_copy_ref/copies_a_file_from_a_copy_ref.yml +271 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_delta/returns_a_cursor_and_list_of_files.yml +184 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_delta/returns_the_files_that_have_changed_since_the_cursor_was_made.yml +361 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_download/a_file/downloads_a_file.yml +58 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_download/a_non-existant_file/raises_a_404.yml +38 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_find/returns_a_single_directory.yml +63 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_find/returns_a_single_file.yml +55 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_ls/a_directory/returns_an_item_array_of_directory_contents.yml +107 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_ls/a_single_file/returns_a_single_item_array_of_if_we_ls_a_file.yml +107 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_ls/no_value/returns_an_array_of_files_and_dirs.yml +115 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_mkdir/creates_dirs_with_tricky_characters.yml +61 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_mkdir/creates_dirs_with_utf8_characters.yml +61 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_mkdir/returns_an_array_of_files_and_dirs.yml +61 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_search/no_path_given/finds_the_file_if_in_root.yml +55 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_search/path_with_leading_slash/finds_the_file.yml +56 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_search/with_path/finds_a_file.yml +56 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_upload/a_file_with_tricky_characters/is_uploaded.yml +56 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_upload/a_file_with_utf8/is_uploaded.yml +56 -0
- data/spec/vcr/cassettes/Dropbox_API_Client/_upload/a_simple_file/is_uploaded.yml +55 -0
- data/spec/vcr/cassettes/Dropbox_API_Dir/_copy/copies_the_dir_properly.yml +120 -0
- data/spec/vcr/cassettes/Dropbox_API_Dir/_destroy/destroys_the_dir_properly.yml +120 -0
- data/spec/vcr/cassettes/Dropbox_API_Dir/_direct_url/gives_the_direct_url.yml +115 -0
- data/spec/vcr/cassettes/Dropbox_API_Dir/_move/moves_the_dir_properly.yml +120 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_copy/copies_the_file_properly.yml +115 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_copy_ref/returns_a_copy_ref_object.yml +104 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_destroy/destroys_the_file_properly.yml +115 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_direct_url/returns_an_Url_object.yml +109 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_download/should_download_the_file.yml +109 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_move/moves_the_file_properly.yml +115 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_restore/restores_the_file_to_a_specific_revision.yml +270 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_revisions/retrieves_all_revisions_as_an_Array_of_File_objects.yml +166 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_share_url/returns_an_Url_object.yml +109 -0
- data/spec/vcr/cassettes/Dropbox_API_File/_thumbnail/downloads_a_thumbnail.yml +427 -0
- data/spec/vcr/cassettes/Dropbox_API_OAuth/_consumer/provides_an_oauth_method.yml +105 -0
- metadata +127 -41
- data/.ruby-version +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5579887689aae6d9cd0627331ed6bc316cf716db
|
4
|
+
data.tar.gz: 92ba58dd36d5563a5ef7ee365c39e58c7762ae4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 899c18b56ef26a3a02e7f8aeb45be847926880b8a3a21e89db9b6c44367a08dd5c2627c7823fd9a994ef22f26ff309007a8a53de14cc5d1d1ccee29a953538ba
|
7
|
+
data.tar.gz: b4d6bc59570bf29e6dc2432840183181f73a5818b5255ee1539689d2439540ada2b49dc8fb7e18356cd0b62a991a7acb4bfd00a722698b920ecce8600fa9761b
|
data/README.markdown
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Dropbox::API - Dropbox Ruby API client (PeteMS fork...)
|
2
2
|
=========
|
3
3
|
|
4
|
-
A Ruby client for the
|
4
|
+
A Ruby client for the Dropbox REST API.
|
5
5
|
|
6
6
|
Goal:
|
7
7
|
|
8
|
-
To deliver a more Rubyesque experience when using the
|
8
|
+
To deliver a more Rubyesque experience when using the Dropbox API.
|
9
9
|
|
10
10
|
Current state:
|
11
11
|
|
@@ -14,11 +14,11 @@ First release, whole API covered.
|
|
14
14
|
Important!!!
|
15
15
|
------------
|
16
16
|
|
17
|
-
From version 0.2.0, Dropbox::API::File#delete and Dropbox::API::Dir#delete *are gone*!!
|
17
|
+
From version 0.2.0, `Dropbox::API::File#delete` and `Dropbox::API::Dir#delete` *are gone*!!
|
18
18
|
|
19
19
|
The reason is that it's based on Hashie::Mash and was screwing Hash#delete.
|
20
20
|
|
21
|
-
It is replaced with Dropbox::API::File#destroy and Dropbox::API::Dir#destroy
|
21
|
+
It is replaced with `Dropbox::API::File#destroy` and `Dropbox::API::Dir#destroy`.
|
22
22
|
|
23
23
|
Installation
|
24
24
|
------------
|
@@ -43,9 +43,10 @@ In order to use this client, you need to have an app created on https://www.drop
|
|
43
43
|
Once you have it, put this configuration somewhere in your code, before you start working with the client.
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
Dropbox::API::Config.app_key =
|
46
|
+
Dropbox::API::Config.app_key = YOUR_APP_KEY
|
47
47
|
Dropbox::API::Config.app_secret = YOUR_APP_SECRET
|
48
|
-
Dropbox::API::Config.mode = "sandbox" # if you have a single-directory app
|
48
|
+
Dropbox::API::Config.mode = "sandbox" # if you have a single-directory app
|
49
|
+
# Dropbox::API::Config.mode = "dropbox" # if your app has access to the whole dropbox
|
49
50
|
```
|
50
51
|
|
51
52
|
Dropbox::API::Client
|
@@ -54,6 +55,9 @@ Dropbox::API::Client
|
|
54
55
|
The client is the base for all communication with the API and wraps around almost all calls
|
55
56
|
available in the API.
|
56
57
|
|
58
|
+
Web-based Authorization
|
59
|
+
-----------------------
|
60
|
+
|
57
61
|
In order to create a Dropbox::API::Client object, you need to have the configuration set up for OAuth.
|
58
62
|
Second thing you need is to have the user authorize your app using OAuth. Here's a short intro
|
59
63
|
on how to do this:
|
@@ -85,19 +89,20 @@ Dropbox::API supplies you with a helper rake which will authorize a single clien
|
|
85
89
|
In order to have this rake available, put this on your Rakefile:
|
86
90
|
|
87
91
|
```ruby
|
92
|
+
require "dropbox-api"
|
88
93
|
require "dropbox-api/tasks"
|
89
94
|
Dropbox::API::Tasks.install
|
90
95
|
```
|
91
96
|
|
92
97
|
You will notice that you have a new rake task - dropbox:authorize
|
93
98
|
|
94
|
-
When you call this Rake task, it will ask you to provide the
|
99
|
+
When you call this Rake task, it will ask you to provide the app key and app secret. Afterwards it will present you with an authorize url on Dropbox.
|
95
100
|
|
96
101
|
Simply go to that url, authorize the app, then press enter in the console.
|
97
102
|
|
98
103
|
The rake task will output valid ruby code which you can use to create a client.
|
99
104
|
|
100
|
-
What differs this from the
|
105
|
+
What differs this from the Dropbox Ruby SDK?
|
101
106
|
--------------------------------------------
|
102
107
|
|
103
108
|
A few things:
|
data/Rakefile
CHANGED
data/dropbox-api.gemspec
CHANGED
@@ -11,20 +11,21 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = "A Ruby client for the DropBox REST API (Originally by marcinbunsch, forked by petems)"
|
12
12
|
s.description = "To deliver a more Rubyesque experience when using the DropBox API (forked by petems)."
|
13
13
|
|
14
|
-
s.
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
15
18
|
|
16
19
|
s.add_dependency 'multi_json', '1.7.9'
|
17
20
|
s.add_dependency 'oauth', '0.4.7'
|
18
21
|
s.add_dependency 'hashie', '2.0.5'
|
22
|
+
s.add_dependency 'backports', '3.6.0'
|
19
23
|
|
20
24
|
s.add_development_dependency 'rspec','2.14.1'
|
21
25
|
s.add_development_dependency 'rake', '10.1.0'
|
22
|
-
s.add_development_dependency 'simplecov', '0.
|
23
|
-
s.add_development_dependency 'ruby
|
24
|
-
s.add_development_dependency 'yajl-ruby', '1.1.0'
|
26
|
+
s.add_development_dependency 'simplecov', '~> 0.8.2'
|
27
|
+
s.add_development_dependency 'yajl-ruby', '~> 1.2.0'
|
25
28
|
|
26
|
-
s.
|
27
|
-
s.
|
28
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
29
|
-
s.require_paths = ["lib"]
|
29
|
+
s.add_development_dependency 'webmock', '~> 1.15.0'
|
30
|
+
s.add_development_dependency 'vcr', '~> 2.8.0'
|
30
31
|
end
|
data/lib/dropbox-api.rb
CHANGED
@@ -15,16 +15,6 @@ module Dropbox
|
|
15
15
|
self.update response
|
16
16
|
end
|
17
17
|
|
18
|
-
def share_url(options = {})
|
19
|
-
response = client.raw.shares({ :path => self.path }.merge(options))
|
20
|
-
Dropbox::API::Object.init(response, client)
|
21
|
-
end
|
22
|
-
|
23
|
-
def direct_url(options = {})
|
24
|
-
response = client.raw.media({ :path => self.path }.merge(options))
|
25
|
-
Dropbox::API::Object.init(response, client)
|
26
|
-
end
|
27
|
-
|
28
18
|
def thumbnail(options = {})
|
29
19
|
client.raw.thumbnails({ :path => self.path }.merge(options))
|
30
20
|
end
|
@@ -38,6 +28,11 @@ module Dropbox
|
|
38
28
|
client.download(self.path)
|
39
29
|
end
|
40
30
|
|
31
|
+
def direct_url(options = {})
|
32
|
+
response = client.raw.media({ :path => self.path }.merge(options))
|
33
|
+
Dropbox::API::Object.init(response, client)
|
34
|
+
end
|
35
|
+
|
41
36
|
end
|
42
37
|
|
43
38
|
end
|
data/lib/dropbox-api/tasks.rb
CHANGED
@@ -12,9 +12,9 @@ module Dropbox
|
|
12
12
|
task :authorize do
|
13
13
|
require "dropbox-api"
|
14
14
|
require "cgi"
|
15
|
-
print "Enter
|
15
|
+
print "Enter dropbox app key: "
|
16
16
|
consumer_key = $stdin.gets.chomp
|
17
|
-
print "Enter
|
17
|
+
print "Enter dropbox app secret: "
|
18
18
|
consumer_secret = $stdin.gets.chomp
|
19
19
|
|
20
20
|
Dropbox::API::Config.app_key = consumer_key
|
data/lib/dropbox-api/version.rb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
require "tempfile"
|
4
4
|
|
5
|
-
describe Dropbox::API::Client do
|
5
|
+
describe Dropbox::API::Client, :vcr => true do
|
6
6
|
|
7
7
|
before do
|
8
|
-
# pending
|
9
8
|
@client = Dropbox::Spec.instance
|
10
9
|
end
|
11
10
|
|
@@ -22,29 +21,22 @@ describe Dropbox::API::Client do
|
|
22
21
|
it "retrieves the account object" do
|
23
22
|
response = @client.account
|
24
23
|
response.should be_an_instance_of(Dropbox::API::Object)
|
24
|
+
response.email.should eql 'testman@example.com'
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#find" do
|
30
30
|
|
31
|
-
before do
|
32
|
-
@filename = "#{Dropbox::Spec.test_dir}/spec-find-file-test-#{Time.now.to_i}.txt"
|
33
|
-
@file = @client.upload @filename, "spec file"
|
34
|
-
|
35
|
-
@dirname = "#{Dropbox::Spec.test_dir}/spec-find-dir-test-#{Time.now.to_i}"
|
36
|
-
@dir = @client.mkdir @dirname
|
37
|
-
end
|
38
|
-
|
39
31
|
it "returns a single file" do
|
40
|
-
response = @client.find(
|
41
|
-
response.path.should ==
|
32
|
+
response = @client.find('baz.txt')
|
33
|
+
response.path.should == 'baz.txt'
|
42
34
|
response.should be_an_instance_of(Dropbox::API::File)
|
43
35
|
end
|
44
36
|
|
45
37
|
it "returns a single directory" do
|
46
|
-
response = @client.find(
|
47
|
-
response.path.should ==
|
38
|
+
response = @client.find('awesome-tests')
|
39
|
+
response.path.should == 'awesome-tests'
|
48
40
|
response.should be_an_instance_of(Dropbox::API::Dir)
|
49
41
|
end
|
50
42
|
|
@@ -52,16 +44,30 @@ describe Dropbox::API::Client do
|
|
52
44
|
|
53
45
|
describe "#ls" do
|
54
46
|
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
context "no value" do
|
48
|
+
|
49
|
+
it "returns an array of files and dirs" do
|
50
|
+
result = @client.ls
|
51
|
+
result.should be_an_instance_of(Array)
|
52
|
+
end
|
58
53
|
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
context "a single file" do
|
56
|
+
it "returns a single item array of if we ls a file" do
|
57
|
+
result = @client.ls('foo.txt')
|
58
|
+
first_file = result.detect { |f| f.class == Dropbox::API::File }
|
59
|
+
result = @client.ls first_file.path
|
60
|
+
result.should be_an_instance_of(Array)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "a directory" do
|
65
|
+
it "returns an item array of directory contents" do
|
66
|
+
result = @client.ls('foo.txt')
|
67
|
+
first_file = result.detect { |f| f.class == Dropbox::API::File }
|
68
|
+
result = @client.ls first_file.path
|
69
|
+
result.should be_an_instance_of(Array)
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
end
|
@@ -69,21 +75,21 @@ describe Dropbox::API::Client do
|
|
69
75
|
describe "#mkdir" do
|
70
76
|
|
71
77
|
it "returns an array of files and dirs" do
|
72
|
-
dirname = "
|
78
|
+
dirname = "awesome-tests"
|
73
79
|
response = @client.mkdir dirname
|
74
80
|
response.path.should == dirname
|
75
81
|
response.should be_an_instance_of(Dropbox::API::Dir)
|
76
82
|
end
|
77
83
|
|
78
84
|
it "creates dirs with tricky characters" do
|
79
|
-
dirname = "
|
85
|
+
dirname = "awesome-tests-|!@\#$%^&*{b}[].;'.,<>?:"
|
80
86
|
response = @client.mkdir dirname
|
81
87
|
response.path.should == dirname.gsub(/[\\\:\?\*\<\>\"\|]+/, '')
|
82
88
|
response.should be_an_instance_of(Dropbox::API::Dir)
|
83
89
|
end
|
84
90
|
|
85
91
|
it "creates dirs with utf8 characters" do
|
86
|
-
dirname = "
|
92
|
+
dirname = "awesome-tests-łółą"
|
87
93
|
response = @client.mkdir dirname
|
88
94
|
response.path.should == dirname
|
89
95
|
response.should be_an_instance_of(Dropbox::API::Dir)
|
@@ -93,26 +99,33 @@ describe Dropbox::API::Client do
|
|
93
99
|
|
94
100
|
describe "#upload" do
|
95
101
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
102
|
+
context "a simple file" do
|
103
|
+
it "is uploaded" do
|
104
|
+
filename = "test.txt"
|
105
|
+
response = @client.upload filename, "Some file"
|
106
|
+
response.path.should == filename
|
107
|
+
response.bytes.should == 9
|
108
|
+
end
|
101
109
|
end
|
102
110
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
111
|
+
context "a file with tricky characters" do
|
112
|
+
it "is uploaded" do
|
113
|
+
filename = "test ,|!@\#$%^&*{b}[].;'.,<>?:.txt"
|
114
|
+
response = @client.upload filename, "Some file"
|
115
|
+
response.path.should == filename
|
116
|
+
response.bytes.should == 9
|
117
|
+
end
|
108
118
|
end
|
109
119
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
120
|
+
context "a file with utf8" do
|
121
|
+
it "is uploaded" do
|
122
|
+
filename = "test łołąó.txt"
|
123
|
+
response = @client.upload filename, "Some file"
|
124
|
+
response.path.should == filename
|
125
|
+
response.bytes.should == 9
|
126
|
+
end
|
115
127
|
end
|
128
|
+
|
116
129
|
end
|
117
130
|
|
118
131
|
describe "#chunked_upload" do
|
@@ -123,14 +136,18 @@ describe Dropbox::API::Client do
|
|
123
136
|
@file = File.open(@filename, "w") {|f| f.write "a"*@size}
|
124
137
|
end
|
125
138
|
|
126
|
-
it "puts a 5MB file in dropbox" do
|
139
|
+
it "puts a 5MB file in dropbox", :vcr => { :match_requests_on => [:host] } do
|
127
140
|
filename = "#{Dropbox::Spec.test_dir}/test-5MB-#{Dropbox::Spec.namespace}.txt"
|
128
141
|
response = @client.chunked_upload filename, File.open(@filename)
|
129
|
-
|
142
|
+
if ENV['RECORDING'] == 'true'
|
143
|
+
response.path.should == filename
|
144
|
+
else
|
145
|
+
response.path.should == 'test-1410120674/test-5MB-1410120674.txt'
|
146
|
+
end
|
130
147
|
response.bytes.should == @size
|
131
148
|
end
|
132
149
|
|
133
|
-
it "yields current offset and upload id" do
|
150
|
+
it "yields current offset and upload id", :vcr => { :match_requests_on => [:host] } do
|
134
151
|
filename = "#{Dropbox::Spec.test_dir}/test-yield-#{Dropbox::Spec.namespace}.txt"
|
135
152
|
log_offset = ""
|
136
153
|
log_upload = ""
|
@@ -140,7 +157,11 @@ describe Dropbox::API::Client do
|
|
140
157
|
log_upload += upload.inspect
|
141
158
|
upload[:upload_id].length.should eq(22)
|
142
159
|
end
|
143
|
-
|
160
|
+
if ENV['RECORDING'] == 'true'
|
161
|
+
response.path.should == filename
|
162
|
+
else
|
163
|
+
response.path.should == 'test-1410121457/test-yield-1410121457.txt'
|
164
|
+
end
|
144
165
|
response.bytes.should == @size
|
145
166
|
log_offset.should match(/[\d]{7},[\d]{7},/)
|
146
167
|
log_upload.should include("Dropbox::API::Object","upload_id=")
|
@@ -154,24 +175,30 @@ describe Dropbox::API::Client do
|
|
154
175
|
|
155
176
|
describe "#search" do
|
156
177
|
|
157
|
-
let(:term) { "
|
158
|
-
|
159
|
-
before do
|
160
|
-
filename = "#{Dropbox::Spec.test_dir}/searchable-test-#{Dropbox::Spec.namespace}.txt"
|
161
|
-
@client.upload filename, "Some file"
|
162
|
-
end
|
178
|
+
let(:term) { "foo.txt" }
|
163
179
|
|
164
180
|
after do
|
165
181
|
@response.size.should == 1
|
166
182
|
@response.first.class.should == Dropbox::API::File
|
167
183
|
end
|
168
184
|
|
169
|
-
|
170
|
-
|
185
|
+
context "with path" do
|
186
|
+
it "finds a file" do
|
187
|
+
@response = @client.search term, :path => "awesome-tests"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context "path with leading slash" do
|
192
|
+
it "finds the file" do
|
193
|
+
@response = @client.search term, :path => "/awesome-tests"
|
194
|
+
end
|
195
|
+
|
171
196
|
end
|
172
197
|
|
173
|
-
|
174
|
-
|
198
|
+
context "no path given" do
|
199
|
+
it "finds the file if in root" do
|
200
|
+
@response = @client.search term
|
201
|
+
end
|
175
202
|
end
|
176
203
|
|
177
204
|
end
|
@@ -179,12 +206,12 @@ describe Dropbox::API::Client do
|
|
179
206
|
describe "#copy_from_copy_ref" do
|
180
207
|
|
181
208
|
it "copies a file from a copy_ref" do
|
182
|
-
filename = "test/searchable-test
|
209
|
+
filename = "test/searchable-test-100.txt"
|
183
210
|
@client.upload filename, "Some file"
|
184
|
-
response = @client.search "searchable-test
|
211
|
+
response = @client.search "searchable-test-100", :path => 'test'
|
185
212
|
ref = response.first.copy_ref['copy_ref']
|
186
213
|
@client.copy_from_copy_ref ref, "#{filename}.copied"
|
187
|
-
response = @client.search "searchable-test
|
214
|
+
response = @client.search "searchable-test-100.txt.copied", :path => 'test'
|
188
215
|
response.size.should == 1
|
189
216
|
response.first.class.should == Dropbox::API::File
|
190
217
|
end
|
@@ -193,23 +220,24 @@ describe Dropbox::API::Client do
|
|
193
220
|
|
194
221
|
describe "#download" do
|
195
222
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
223
|
+
context "a file" do
|
224
|
+
it "downloads a file" do
|
225
|
+
file = @client.download "awesome-tests/foo.txt"
|
226
|
+
file.should == "Some file"
|
227
|
+
end
|
200
228
|
end
|
201
229
|
|
202
|
-
|
203
|
-
|
204
|
-
@client.download "
|
205
|
-
|
230
|
+
context "a non-existant file" do
|
231
|
+
it "raises a 404" do
|
232
|
+
expect { @client.download "awesome-tests/no.txt"}.to raise_error(Dropbox::API::Error::NotFound)
|
233
|
+
end
|
206
234
|
end
|
207
235
|
|
208
236
|
end
|
209
237
|
|
210
238
|
describe "#delta" do
|
211
239
|
it "returns a cursor and list of files" do
|
212
|
-
filename = "
|
240
|
+
filename = "awesome-tests/delta-test-foo.txt"
|
213
241
|
@client.upload filename, 'Some file'
|
214
242
|
response = @client.delta
|
215
243
|
cursor, files = response.cursor, response.entries
|
@@ -219,8 +247,8 @@ describe Dropbox::API::Client do
|
|
219
247
|
end
|
220
248
|
|
221
249
|
it "returns the files that have changed since the cursor was made" do
|
222
|
-
filename = "
|
223
|
-
delete_filename = "
|
250
|
+
filename = "awesome-tests/delta-test-bar.txt"
|
251
|
+
delete_filename = "awesome-tests/delta-test-baz.txt"
|
224
252
|
@client.upload delete_filename, 'Some file'
|
225
253
|
response = @client.delta
|
226
254
|
cursor, files = response.cursor, response.entries
|