instapaper 0.3.0 → 1.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +1 -1
- data/README.md +62 -38
- data/instapaper.gemspec +21 -30
- data/lib/instapaper.rb +0 -25
- data/lib/instapaper/api.rb +15 -0
- data/lib/instapaper/{client/account.rb → api/accounts.rb} +5 -5
- data/lib/instapaper/api/bookmarks.rb +77 -0
- data/lib/instapaper/{client/folder.rb → api/folders.rb} +12 -11
- data/lib/instapaper/api/highlights.rb +33 -0
- data/lib/instapaper/api/oauth.rb +17 -0
- data/lib/instapaper/bookmark.rb +21 -0
- data/lib/instapaper/bookmark_list.rb +20 -0
- data/lib/instapaper/client.rb +40 -28
- data/lib/instapaper/credentials.rb +12 -0
- data/lib/instapaper/error.rb +78 -0
- data/lib/instapaper/folder.rb +17 -0
- data/lib/instapaper/highlight.rb +16 -0
- data/lib/instapaper/http/headers.rb +45 -0
- data/lib/instapaper/http/qline_parser.rb +9 -0
- data/lib/instapaper/http/request.rb +84 -0
- data/lib/instapaper/http/utils.rb +67 -0
- data/lib/instapaper/user.rb +14 -0
- data/lib/instapaper/version.rb +1 -1
- metadata +63 -209
- data/.gemtest +0 -0
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -8
- data/.yardopts +0 -3
- data/Gemfile +0 -7
- data/Rakefile +0 -13
- data/lib/faraday/response/raise_http_1xxx.rb +0 -65
- data/lib/instapaper/authentication.rb +0 -32
- data/lib/instapaper/client/bookmark.rb +0 -81
- data/lib/instapaper/client/user.rb +0 -19
- data/lib/instapaper/configuration.rb +0 -88
- data/lib/instapaper/connection.rb +0 -35
- data/lib/instapaper/request.rb +0 -22
- data/spec/faraday/response_spec.rb +0 -22
- data/spec/fixtures/access_token.qline +0 -1
- data/spec/fixtures/bookmarks_add.json +0 -1
- data/spec/fixtures/bookmarks_archive.json +0 -1
- data/spec/fixtures/bookmarks_get_text.txt +0 -299
- data/spec/fixtures/bookmarks_list.json +0 -5
- data/spec/fixtures/bookmarks_move.json +0 -1
- data/spec/fixtures/bookmarks_star.json +0 -1
- data/spec/fixtures/bookmarks_unarchive.json +0 -1
- data/spec/fixtures/bookmarks_unstar.json +0 -1
- data/spec/fixtures/bookmarks_update_read_progress.json +0 -1
- data/spec/fixtures/folders_add.json +0 -1
- data/spec/fixtures/folders_delete.json +0 -1
- data/spec/fixtures/folders_list.json +0 -1
- data/spec/fixtures/folders_set_order.json +0 -1
- data/spec/fixtures/invalid_credentials.qline +0 -1
- data/spec/fixtures/verify_credentials.json +0 -1
- data/spec/instapaper/client/account_spec.rb +0 -27
- data/spec/instapaper/client/bookmark_spec.rb +0 -234
- data/spec/instapaper/client/folder_spec.rb +0 -89
- data/spec/instapaper/client/user_spec.rb +0 -36
- data/spec/instapaper/client_spec.rb +0 -65
- data/spec/instapaper_spec.rb +0 -85
- data/spec/spec_helper.rb +0 -52
@@ -1,5 +0,0 @@
|
|
1
|
-
[{"type":"meta"},
|
2
|
-
{"type":"user","user_id":1075837,"username":"steve.agalloco@gmail.com","subscription_is_active":"1"},
|
3
|
-
{"type":"bookmark","bookmark_id":170939225,"url":"http:\/\/www.igvita.com\/2010\/11\/17\/routing-with-ruby-zeromq-devices\/","title":"Routing with Ruby & ZeroMQ Devices","description":"ZeroMQ sockets provide message-oriented messaging, support for multiple transports, transparent setup and teardown, and an entire array of routing patterns via different socket types","time":1307319089,"starred":"0","private_source":"","hash":"PGU0MMPw","progress":0,"progress_timestamp":0},
|
4
|
-
{"type":"bookmark","bookmark_id":169529989,"url":"http:\/\/www.fastcodesign.com\/1662169\/ideos-axioms-for-starting-disruptive-new-businesses","title":"Ideo's Axioms for Starting Disruptive New Businesses | Co.Design","description":"www.fastcodesign.com","time":1306963988,"starred":"0","private_source":"","hash":"v27qHZc2","progress":"0","progress_timestamp":1307145892}
|
5
|
-
]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"bookmark","bookmark_id":169529989,"url":"http:\/\/www.fastcodesign.com\/1662169\/ideos-axioms-for-starting-disruptive-new-businesses","title":"Ideo's Axioms for Starting Disruptive New Businesses | Co.Design","description":"www.fastcodesign.com","time":1307586766,"starred":"0","private_source":"","hash":"9GZzaC8U","progress":"0","progress_timestamp":1307585389}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"bookmark","bookmark_id":170939225,"url":"http:\/\/www.igvita.com\/2010\/11\/17\/routing-with-ruby-zeromq-devices\/","title":"Routing with Ruby & ZeroMQ Devices","description":"ZeroMQ sockets provide message-oriented messaging, support for multiple transports, transparent setup and teardown, and an entire array of routing patterns via different socket types","time":1307319089,"starred":"1","private_source":"","hash":"PGU0MMPw","progress":0,"progress_timestamp":0}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"bookmark","bookmark_id":169529989,"url":"http:\/\/www.fastcodesign.com\/1662169\/ideos-axioms-for-starting-disruptive-new-businesses","title":"Ideo's Axioms for Starting Disruptive New Businesses | Co.Design","description":"www.fastcodesign.com","time":1307507347,"starred":"0","private_source":"","hash":"v27qHZc2","progress":"0","progress_timestamp":1307145892}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"bookmark","bookmark_id":170939225,"url":"http:\/\/www.igvita.com\/2010\/11\/17\/routing-with-ruby-zeromq-devices\/","title":"Routing with Ruby & ZeroMQ Devices","description":"ZeroMQ sockets provide message-oriented messaging, support for multiple transports, transparent setup and teardown, and an entire array of routing patterns via different socket types","time":1307319089,"starred":"0","private_source":"","hash":"PGU0MMPw","progress":0,"progress_timestamp":0}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"bookmark","bookmark_id":169529989,"url":"http:\/\/www.fastcodesign.com\/1662169\/ideos-axioms-for-starting-disruptive-new-businesses","title":"Ideo's Axioms for Starting Disruptive New Businesses | Co.Design","description":"www.fastcodesign.com","time":1307507347,"starred":"0","private_source":"","hash":"6n9G6qFt","progress":"0.5","progress_timestamp":1307585332}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"folder","folder_id":1121141,"title":"Ruby","sync_to_mobile":"1","position":1307330035}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"folder","folder_id":1121173,"title":"Ruby","sync_to_mobile":"1","position":1307331865},{"type":"folder","folder_id":1121174,"title":"JavaScript","sync_to_mobile":"1","position":1307331865}]
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"folder","folder_id":1121174,"title":"JavaScript","sync_to_mobile":"1","position":1},{"type":"folder","folder_id":1121173,"title":"Ruby","sync_to_mobile":"1","position":2}]
|
@@ -1 +0,0 @@
|
|
1
|
-
Invalid xAuth credentials.
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"type":"user","user_id":54321,"username":"TestUserOMGLOL"}]
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Instapaper::Client::Account do
|
4
|
-
before(:each) do
|
5
|
-
@client = Instapaper::Client.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.verify_credentials' do
|
9
|
-
before do
|
10
|
-
stub_post("account/verify_credentials").
|
11
|
-
to_return(:body => fixture("verify_credentials.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should get the correct resource" do
|
15
|
-
@client.verify_credentials
|
16
|
-
a_post("account/verify_credentials").
|
17
|
-
should have_been_made
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return the user" do
|
21
|
-
user = @client.verify_credentials.first
|
22
|
-
user.should be_a Hashie::Rash
|
23
|
-
user.username.should == 'TestUserOMGLOL'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,234 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Instapaper::Client::Bookmark do
|
4
|
-
before(:each) do
|
5
|
-
@client = Instapaper::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.bookmarks' do
|
9
|
-
before do
|
10
|
-
stub_post("bookmarks/list").
|
11
|
-
to_return(:body => fixture("bookmarks_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should get the correct resource" do
|
15
|
-
@client.bookmarks
|
16
|
-
a_post("bookmarks/list").
|
17
|
-
should have_been_made
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return an array containing bookmarks on success" do
|
21
|
-
bookmarks = @client.bookmarks
|
22
|
-
bookmarks.should be_an Array
|
23
|
-
bookmarks.size.should == 2
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should remove the meta and current user objects from the array" do
|
27
|
-
bookmarks = @client.bookmarks
|
28
|
-
bookmarks.each do |bookmark|
|
29
|
-
bookmark.should be_a Hashie::Rash
|
30
|
-
bookmark.type.should == 'bookmark'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '.update_read_progress' do
|
36
|
-
before do
|
37
|
-
@time = Time.now
|
38
|
-
stub_post("bookmarks/update_read_progress").
|
39
|
-
to_return(:body => fixture("bookmarks_update_read_progress.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should get the correct resource" do
|
43
|
-
@client.update_read_progress(123, 0.5, @time)
|
44
|
-
a_post("bookmarks/update_read_progress").with(:body => {:bookmark_id => "123", :progress => '0.5', :progress_timestamp => @time.to_i.to_s }).
|
45
|
-
should have_been_made
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return an array containing bookmarks on success" do
|
49
|
-
bookmark = @client.update_read_progress(123, 0.5, @time)
|
50
|
-
bookmark.should be_a Hashie::Rash
|
51
|
-
bookmark.type.should == 'bookmark'
|
52
|
-
bookmark.progress.should == "0.5"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '.add_bookmark' do
|
57
|
-
before do
|
58
|
-
stub_post("bookmarks/add").
|
59
|
-
to_return(:body => fixture('bookmarks_add.json'), :headers => {:content_type => "application/json; charset=utf-8"})
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should get the correct resource" do
|
63
|
-
@client.add_bookmark('http://someurl.com', :title => 'This is the title', :description => 'This is the description')
|
64
|
-
a_post("bookmarks/add").with(:body => {:url => "http://someurl.com", :title => 'This is the title', :description => 'This is the description' }).
|
65
|
-
should have_been_made
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should return the bookmark on success" do
|
69
|
-
bookmark = @client.add_bookmark('http://someurl.com', :title => 'This is the title', :description => 'This is the description')
|
70
|
-
bookmark.should be_a Hashie::Rash
|
71
|
-
bookmark.type.should == 'bookmark'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '.delete_bookmark' do
|
76
|
-
before do
|
77
|
-
stub_post("bookmarks/delete").
|
78
|
-
to_return(:body => '[]', :headers => {:content_type => "application/json; charset=utf-8"})
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should get the correct resource" do
|
82
|
-
@client.delete_bookmark(123)
|
83
|
-
a_post("bookmarks/delete").with(:body => {:bookmark_id => "123" }).
|
84
|
-
should have_been_made
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should return an array containing bookmarks on success" do
|
88
|
-
confirm = @client.delete_bookmark(123)
|
89
|
-
confirm.should be_an Array
|
90
|
-
confirm.should be_empty
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '.star' do
|
95
|
-
before do
|
96
|
-
stub_post("bookmarks/star").
|
97
|
-
to_return(:body => fixture("bookmarks_star.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should get the correct resource" do
|
101
|
-
@client.star(123)
|
102
|
-
a_post("bookmarks/star").with(:body => {:bookmark_id => "123" }).
|
103
|
-
should have_been_made
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should return a starred bookmark on success" do
|
107
|
-
bookmark = @client.star(123)
|
108
|
-
bookmark.should be_a Hashie::Rash
|
109
|
-
bookmark.type.should == 'bookmark'
|
110
|
-
bookmark.starred.should == '1'
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should be aliased as .star_bookmark' do
|
114
|
-
@client.star(123).should == @client.star_bookmark(123)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '.unstar' do
|
119
|
-
before do
|
120
|
-
stub_post("bookmarks/unstar").
|
121
|
-
to_return(:body => fixture("bookmarks_unstar.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should get the correct resource" do
|
125
|
-
@client.unstar(123)
|
126
|
-
a_post("bookmarks/unstar").with(:body => {:bookmark_id => "123" }).
|
127
|
-
should have_been_made
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should return an unstarred bookmark on success" do
|
131
|
-
bookmark = @client.unstar(123)
|
132
|
-
bookmark.should be_a Hashie::Rash
|
133
|
-
bookmark.type.should == 'bookmark'
|
134
|
-
bookmark.starred.should == '0'
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'should be aliased as .unstar_bookmark' do
|
138
|
-
@client.unstar(123).should == @client.unstar_bookmark(123)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe '.archive' do
|
143
|
-
before do
|
144
|
-
stub_post("bookmarks/archive").
|
145
|
-
to_return(:body => fixture("bookmarks_archive.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should get the correct resource" do
|
149
|
-
@client.archive(123)
|
150
|
-
a_post("bookmarks/archive").with(:body => {:bookmark_id => "123" }).
|
151
|
-
should have_been_made
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should return the bookmark on success" do
|
155
|
-
bookmark = @client.archive(123)
|
156
|
-
bookmark.should be_a Hashie::Rash
|
157
|
-
bookmark.type.should == 'bookmark'
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'should be aliased as .archive_bookmark' do
|
161
|
-
@client.archive(123).should == @client.archive_bookmark(123)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe '.unarchive' do
|
166
|
-
before do
|
167
|
-
stub_post("bookmarks/unarchive").
|
168
|
-
to_return(:body => fixture("bookmarks_unarchive.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should get the correct resource" do
|
172
|
-
@client.unarchive(123)
|
173
|
-
a_post("bookmarks/unarchive").with(:body => {:bookmark_id => "123" }).
|
174
|
-
should have_been_made
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should return the bookmark on success" do
|
178
|
-
bookmark = @client.unarchive(123)
|
179
|
-
bookmark.should be_a Hashie::Rash
|
180
|
-
bookmark.type.should == 'bookmark'
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'should be aliased as .unarchive_bookmark' do
|
184
|
-
@client.unarchive(123).should == @client.unarchive_bookmark(123)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe '.move' do
|
189
|
-
before do
|
190
|
-
stub_post("bookmarks/move").
|
191
|
-
to_return(:body => fixture("bookmarks_move.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should get the correct resource" do
|
195
|
-
@client.move(123, 12345)
|
196
|
-
a_post("bookmarks/move").with(:body => {:bookmark_id => "123", :folder_id => "12345" }).
|
197
|
-
should have_been_made
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should return the bookmark on success" do
|
201
|
-
bookmark = @client.move(123, 12345)
|
202
|
-
bookmark.should be_a Hashie::Rash
|
203
|
-
bookmark.type.should == 'bookmark'
|
204
|
-
end
|
205
|
-
|
206
|
-
it 'should be aliased as .move_bookmark' do
|
207
|
-
@client.move(123, 12345).should == @client.move_bookmark(123, 12345)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe '.text' do
|
212
|
-
before do
|
213
|
-
stub_post("bookmarks/get_text").
|
214
|
-
to_return(:body => fixture("bookmarks_get_text.txt"), :headers => {:content_type => "text/html; charset=utf-8"})
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should get the correct resource" do
|
218
|
-
@client.text(123)
|
219
|
-
a_post("bookmarks/get_text").with(:body => {:bookmark_id => "123" }).
|
220
|
-
should have_been_made
|
221
|
-
end
|
222
|
-
|
223
|
-
it "should return the bookmark's html on success" do
|
224
|
-
bookmark = @client.text(123)
|
225
|
-
bookmark.length.should > 0
|
226
|
-
bookmark.should include("Ideo's Axioms for Starting Disruptive New Businesses")
|
227
|
-
end
|
228
|
-
|
229
|
-
it 'should be aliased as .get_text' do
|
230
|
-
@client.text(123).should == @client.get_text(123)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Instapaper::Client::Folder do
|
4
|
-
before(:each) do
|
5
|
-
@client = Instapaper::Client.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.folders' do
|
9
|
-
before do
|
10
|
-
stub_post("folders/list").
|
11
|
-
to_return(:body => fixture("folders_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should get the correct resource" do
|
15
|
-
@client.folders
|
16
|
-
a_post("folders/list").
|
17
|
-
should have_been_made
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return an array containing folders on success" do
|
21
|
-
folders = @client.folders
|
22
|
-
folders.should be_an Array
|
23
|
-
folders.size.should == 2
|
24
|
-
folders.first.should be_a Hashie::Rash
|
25
|
-
folders.first['title'].should == 'Ruby'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '.add_folder' do
|
30
|
-
before do
|
31
|
-
stub_post("folders/add").with(:body => {:title => "Ruby" }).
|
32
|
-
to_return(:body => fixture("folders_add.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should get the correct resource" do
|
36
|
-
@client.add_folder("Ruby")
|
37
|
-
a_post("folders/add").
|
38
|
-
should have_been_made
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should return an array containing the new folder on success" do
|
42
|
-
folders = @client.add_folder("Ruby")
|
43
|
-
folders.should be_an Array
|
44
|
-
folders.should_not be_empty
|
45
|
-
folders.first.should be_a Hashie::Rash
|
46
|
-
folders.first['title'].should == 'Ruby'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '.delete_folder' do
|
51
|
-
before do
|
52
|
-
stub_post("folders/delete"). with(:body => {:folder_id => "1" }).
|
53
|
-
to_return(:body => fixture("folders_delete.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should get the correct resource" do
|
57
|
-
@client.delete_folder("1")
|
58
|
-
a_post("folders/delete").
|
59
|
-
should have_been_made
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return an empty array on success" do
|
63
|
-
confirm = @client.delete_folder("1")
|
64
|
-
confirm.should be_an Array
|
65
|
-
confirm.should be_empty
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '.set_order' do
|
70
|
-
before do
|
71
|
-
stub_post("folders/set_order"). with(:body => {:order => "1121173:2,1121174:1" }).
|
72
|
-
to_return(:body => fixture("folders_set_order.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should get the correct resource" do
|
76
|
-
@client.set_order(['1121173:2','1121174:1'])
|
77
|
-
a_post("folders/set_order").
|
78
|
-
should have_been_made
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should return an array reflecting the new order on success" do
|
82
|
-
folders = @client.set_order(['1121173:2','1121174:1'])
|
83
|
-
folders.should be_an Array
|
84
|
-
folders.first.should be_a Hashie::Rash
|
85
|
-
folders.first['position'].should == 1
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Instapaper::Client::User do
|
4
|
-
before(:each) do
|
5
|
-
@client = Instapaper::Client.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.access_token' do
|
9
|
-
before do
|
10
|
-
stub_post("oauth/access_token").with(:body => { :x_auth_username => 'ohai', :x_auth_password => 'p455w0rd', :x_auth_mode => 'client_auth'}).
|
11
|
-
to_return(:body => fixture("access_token.qline"), :headers => {:content_type => "text/plain; charset=utf-8"})
|
12
|
-
stub_post("oauth/access_token").with(:body => { :x_auth_username => 'inval1d', :x_auth_password => 'cr3dentials', :x_auth_mode => 'client_auth'}).
|
13
|
-
to_return(:body => fixture("invalid_credentials.qline"), :headers => {:content_type => "text/plain; charset=utf-8"})
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should get the correct resource" do
|
17
|
-
@client.access_token('ohai', 'p455w0rd')
|
18
|
-
a_post("oauth/access_token").
|
19
|
-
should have_been_made
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should return the a hash containing an oauth token and secret" do
|
23
|
-
tokens = @client.access_token('ohai', 'p455w0rd')
|
24
|
-
tokens.should be_a Hash
|
25
|
-
tokens.key?('oauth_token').should be_true
|
26
|
-
tokens.key?('oauth_token_secret').should be_true
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return a hash containing the error on invalid credentials" do
|
30
|
-
tokens = @client.access_token('inval1d', 'cr3dentials')
|
31
|
-
tokens.should be_a Hash
|
32
|
-
tokens.key?('error').should be_true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Instapaper::Client do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@options = { :adapter => :em_synchrony, :user_agent => 'Instapaper::Client spec' }
|
7
|
-
@keys = Instapaper::Configuration::VALID_OPTIONS_KEYS
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '.new' do
|
11
|
-
before(:each) do
|
12
|
-
@keys.each do |key|
|
13
|
-
Instapaper.send("#{key}=", key)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
after do
|
18
|
-
Instapaper.reset
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'with module configuration' do
|
22
|
-
it "should inherit module configuration" do
|
23
|
-
api = Instapaper::Client.new
|
24
|
-
@keys.each do |key|
|
25
|
-
api.send(key).should eq(key)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'with class configuration' do
|
31
|
-
context "during initialization" do
|
32
|
-
it "should override module configuration" do
|
33
|
-
api = Instapaper::Client.new(@options)
|
34
|
-
@keys.each do |key|
|
35
|
-
h = @options.has_key?(key) ? @options : Instapaper.options
|
36
|
-
api.send(key).should eq(h[key])
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "after initialization" do
|
42
|
-
it "should override module configuration after initialization" do
|
43
|
-
api = Instapaper::Client.new
|
44
|
-
@options.each do |key, value|
|
45
|
-
api.send("#{key}=", value)
|
46
|
-
end
|
47
|
-
@keys.each do |key|
|
48
|
-
h = @options.has_key?(key) ? @options : Instapaper.options
|
49
|
-
api.send(key).should eq(h[key])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '.endpoint_with_prefix' do
|
57
|
-
before(:each) do
|
58
|
-
@client = Instapaper::Client.new
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should return the ' do
|
62
|
-
@client.endpoint_with_prefix.should == Instapaper.endpoint + Instapaper.path_prefix
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|