rightsignature 0.1.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +42 -44
- data/lib/rightsignature.rb +0 -49
- data/lib/rightsignature/account.rb +14 -16
- data/lib/rightsignature/connection.rb +116 -64
- data/lib/rightsignature/connection/oauth_connection.rb +65 -55
- data/lib/rightsignature/connection/token_connection.rb +16 -11
- data/lib/rightsignature/document.rb +217 -220
- data/lib/rightsignature/template.rb +217 -221
- data/lib/rightsignature/version.rb +1 -1
- data/spec/account_spec.rb +22 -22
- data/spec/api_token_connection_spec.rb +13 -10
- data/spec/configuration_spec.rb +42 -42
- data/spec/connection_spec.rb +91 -91
- data/spec/document_spec.rb +60 -60
- data/spec/oauth_connnection_spec.rb +39 -34
- data/spec/spec_helper.rb +1 -1
- data/spec/template_spec.rb +62 -62
- metadata +2 -2
data/spec/document_spec.rb
CHANGED
@@ -1,94 +1,94 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
3
|
describe RightSignature::Document do
|
4
|
-
describe "
|
4
|
+
describe "documents_list" do
|
5
5
|
it "should GET /documents.xml" do
|
6
|
-
|
7
|
-
|
6
|
+
@rs.should_receive(:get).with('/api/documents.xml', {})
|
7
|
+
@rs.documents_list
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should pass search options to /api/templates.xml" do
|
11
|
-
|
12
|
-
|
11
|
+
@rs.should_receive(:get).with('/api/documents.xml', {:search => "search", :page => 2})
|
12
|
+
@rs.documents_list(:search => "search", :page => 2)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should convert array in options :tags into a string" do
|
16
|
-
|
17
|
-
|
16
|
+
@rs.should_receive(:get).with('/api/documents.xml', {:tags => "hello,what_is:up"})
|
17
|
+
@rs.documents_list(:tags => ['hello', {'what_is' => "up"}])
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should convert array of options :state into a string" do
|
21
|
-
|
22
|
-
|
21
|
+
@rs.should_receive(:get).with('/api/documents.xml', {:state => 'pending,trashed'})
|
22
|
+
@rs.documents_list(:state => ['pending', 'trashed'])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "details" do
|
27
27
|
it "should GET /api/documentsMYGUID.xml" do
|
28
|
-
|
29
|
-
|
28
|
+
@rs.should_receive(:get).with('/api/documents/MYGUID.xml')
|
29
|
+
@rs.document_details('MYGUID')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "details" do
|
34
34
|
it "should GET /api/documentsMYGUID.xml" do
|
35
|
-
|
36
|
-
|
35
|
+
@rs.should_receive(:get).with('/api/documents/MYGUID.xml')
|
36
|
+
@rs.document_details('MYGUID')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe "
|
40
|
+
describe "documents_batch_details" do
|
41
41
|
it "should GET /api/documentsMYGUID1,MYGUID2.xml" do
|
42
|
-
|
43
|
-
|
42
|
+
@rs.should_receive(:get).with('/api/documents/MYGUID1,MYGUID2/batch_details.xml')
|
43
|
+
@rs.documents_batch_details(['MYGUID1','MYGUID2'])
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "send_reminder" do
|
48
48
|
it "should POST /api/documentsMYGUID/send_reminders.xml" do
|
49
|
-
|
50
|
-
|
49
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/send_reminders.xml', {})
|
50
|
+
@rs.send_reminder('MYGUID')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "trash" do
|
55
55
|
it "should POST /api/documents/MYGUID/trash.xml" do
|
56
|
-
|
57
|
-
|
56
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/trash.xml', {})
|
57
|
+
@rs.trash_document('MYGUID')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe "
|
61
|
+
describe "extend_document_expiration" do
|
62
62
|
it "should POST /api/documents/MYGUID/extend_expiration.xml" do
|
63
|
-
|
64
|
-
|
63
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/extend_expiration.xml', {})
|
64
|
+
@rs.extend_document_expiration('MYGUID')
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
describe "
|
68
|
+
describe "update_document_tags" do
|
69
69
|
it "should POST /api/documents/MYGUID/update_tags.xml" do
|
70
|
-
|
71
|
-
|
70
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/update_tags.xml', {:tags => []})
|
71
|
+
@rs.update_document_tags('MYGUID', [])
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should normalize tags array into expected hash format" do
|
75
|
-
|
75
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/update_tags.xml', {
|
76
76
|
:tags => [{:tag => {:name => 'myNewOne'}}, {:tag => {:name => 'should_replace', :value => 'the_old_new'}}]
|
77
77
|
})
|
78
|
-
|
78
|
+
@rs.update_document_tags('MYGUID', ["myNewOne", {"should_replace" => "the_old_new"}])
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should allow empty tags array" do
|
82
|
-
|
82
|
+
@rs.should_receive(:post).with('/api/documents/MYGUID/update_tags.xml', {
|
83
83
|
:tags => []
|
84
84
|
})
|
85
|
-
|
85
|
+
@rs.update_document_tags('MYGUID', [])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
describe "send_document" do
|
90
90
|
it "should POST /api/documents.xml with document hash containing given subject, document data, recipients, and action of 'send'" do
|
91
|
-
|
91
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
92
92
|
:document => {
|
93
93
|
:subject => "subby",
|
94
94
|
:document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"},
|
@@ -97,11 +97,11 @@ describe RightSignature::Document do
|
|
97
97
|
}
|
98
98
|
})
|
99
99
|
document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"}
|
100
|
-
|
100
|
+
@rs.send_document("subby", [], document_data)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should POST /api/documents.xml should convert recipients into normalized format" do
|
104
|
-
|
104
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
105
105
|
:document => {
|
106
106
|
:subject => "subby",
|
107
107
|
:document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"},
|
@@ -115,11 +115,11 @@ describe RightSignature::Document do
|
|
115
115
|
document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"}
|
116
116
|
recipients = [{:name => "Signy Sign", :email => "signy@example.com", :role => "signer"}, {:name => "Cee Cee", :email => "ccme@example.com", :role => "cc"}]
|
117
117
|
|
118
|
-
|
118
|
+
@rs.send_document("subby", recipients, document_data)
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should POST /api/documents.xml with options" do
|
122
|
-
|
122
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
123
123
|
:document => {
|
124
124
|
:subject => "subby",
|
125
125
|
:document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"},
|
@@ -139,13 +139,13 @@ describe RightSignature::Document do
|
|
139
139
|
:description => "My descript",
|
140
140
|
:callback_url => "http://example.com/call"
|
141
141
|
}
|
142
|
-
|
142
|
+
@rs.send_document("subby", recipients, document_data, options)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "send_document_from_data" do
|
147
147
|
it "should POST /api/documents.xml with document hash containing given subject, Base64 encoded version of document data, recipients, and action of 'send'" do
|
148
|
-
|
148
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
149
149
|
:document => {
|
150
150
|
:subject => "subby",
|
151
151
|
:document_data => {:type => 'base64', :filename => "my fresh upload.pdf", :value => Base64::encode64("THIS IS MY data")},
|
@@ -153,11 +153,11 @@ describe RightSignature::Document do
|
|
153
153
|
:action => "send"
|
154
154
|
}
|
155
155
|
})
|
156
|
-
|
156
|
+
@rs.send_document_from_data("THIS IS MY data", "my fresh upload.pdf", "subby", [])
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should POST /api/documents.xml with options" do
|
160
|
-
|
160
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
161
161
|
:document => {
|
162
162
|
:subject => "subby",
|
163
163
|
:action => "send",
|
@@ -176,7 +176,7 @@ describe RightSignature::Document do
|
|
176
176
|
:description => "My descript",
|
177
177
|
:callback_url => "http://example.com/call"
|
178
178
|
}
|
179
|
-
|
179
|
+
@rs.send_document_from_data("THIS", "uploaded.pdf", "subby", recipients, options)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -186,7 +186,7 @@ describe RightSignature::Document do
|
|
186
186
|
file = File.new(File.dirname(__FILE__) + '/spec_helper.rb')
|
187
187
|
fake_data = "abc"
|
188
188
|
File.should_receive(:read).with(file).and_return(fake_data)
|
189
|
-
|
189
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
190
190
|
:document => {
|
191
191
|
:subject => "subby",
|
192
192
|
:action => "send",
|
@@ -195,14 +195,14 @@ describe RightSignature::Document do
|
|
195
195
|
}
|
196
196
|
})
|
197
197
|
|
198
|
-
|
198
|
+
@rs.send_document_from_file(file, "subby", [])
|
199
199
|
end
|
200
200
|
|
201
201
|
it "should open path to file and base64 encode it" do
|
202
202
|
file_path = '/tmp/temp.pdf'
|
203
203
|
fake_data = "abc"
|
204
204
|
File.should_receive(:read).with(file_path).and_return(fake_data)
|
205
|
-
|
205
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
206
206
|
:document => {
|
207
207
|
:subject => "subby",
|
208
208
|
:action => "send",
|
@@ -210,14 +210,14 @@ describe RightSignature::Document do
|
|
210
210
|
:recipients => []
|
211
211
|
}
|
212
212
|
})
|
213
|
-
|
213
|
+
@rs.send_document_from_file(file_path, "subby", [])
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should POST /api/documents.xml with options" do
|
217
217
|
file_path = '/tmp/temp.pdf'
|
218
218
|
fake_data = "abc"
|
219
219
|
File.should_receive(:read).with(file_path).and_return(fake_data)
|
220
|
-
|
220
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
221
221
|
:document => {
|
222
222
|
:subject => "subby",
|
223
223
|
:action => "send",
|
@@ -236,13 +236,13 @@ describe RightSignature::Document do
|
|
236
236
|
:description => "My descript",
|
237
237
|
:callback_url => "http://example.com/call"
|
238
238
|
}
|
239
|
-
|
239
|
+
@rs.send_document_from_file(file_path, "subby", recipients, options)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
243
243
|
describe "generate_document_url" do
|
244
244
|
it "should POST /api/documents.xml with redirect action and return https://rightsignature.com/builder/new?rt=REDIRECT_TOKEN" do
|
245
|
-
|
245
|
+
@rs.should_receive(:post).with("/api/documents.xml", {
|
246
246
|
:document => {
|
247
247
|
:subject => "subjy",
|
248
248
|
:action => "redirect",
|
@@ -250,45 +250,45 @@ describe RightSignature::Document do
|
|
250
250
|
:recipients => [],
|
251
251
|
}
|
252
252
|
}).and_return({"document"=>{"redirect_token" => "REDIRECT_TOKEN"}})
|
253
|
-
|
253
|
+
@rs.generate_document_redirect_url("subjy", [], {}).should == "#{@rs.site}/builder/new?rt=REDIRECT_TOKEN"
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
-
describe "
|
257
|
+
describe "get_document_signer_links_for" do
|
258
258
|
it "should GET /api/documents/GUID123/signer_links.xml and return urls for signers" do
|
259
|
-
|
259
|
+
@rs.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {}).and_return({'document' => {'signer_links' => {'signer_link' => [
|
260
260
|
{"signer_token" => "avx37", "name" => "John Bellingham"},
|
261
261
|
{"signer_token" => "fdh89", "name" => "Righty Jones"}]
|
262
262
|
}}})
|
263
263
|
|
264
|
-
response =
|
264
|
+
response = @rs.get_document_signer_links_for("GUID123")
|
265
265
|
response.size.should == 2
|
266
|
-
response.include?({"name" => "John Bellingham", "url" => "#{
|
267
|
-
response.include?({"name" => "Righty Jones", "url" => "#{
|
266
|
+
response.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=avx37"}).should be_true
|
267
|
+
response.include?({"name" => "Righty Jones", "url" => "#{@rs.site}/signatures/embedded?rt=fdh89"}).should be_true
|
268
268
|
end
|
269
269
|
|
270
270
|
it "should GET /api/documents/GUID123/signer_links.xml with URI encoded redirect location and return urls for signers" do
|
271
|
-
|
271
|
+
@rs.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {:redirect_location => "http://google.com/redirected%20location"}
|
272
272
|
).and_return({'document' => {'signer_links' => {'signer_link' => [
|
273
273
|
{"signer_token" => "avx37", "name" => "John Bellingham"},
|
274
274
|
{"signer_token" => "fdh89", "name" => "Righty Jones"}]
|
275
275
|
}}})
|
276
276
|
|
277
|
-
response =
|
277
|
+
response = @rs.get_document_signer_links_for("GUID123", "http://google.com/redirected location")
|
278
278
|
response.size.should == 2
|
279
|
-
response.include?({"name" => "John Bellingham", "url" => "#{
|
280
|
-
response.include?({"name" => "Righty Jones", "url" => "#{
|
279
|
+
response.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=avx37"}).should be_true
|
280
|
+
response.include?({"name" => "Righty Jones", "url" => "#{@rs.site}/signatures/embedded?rt=fdh89"}).should be_true
|
281
281
|
end
|
282
282
|
|
283
283
|
it "should GET /api/documents/GUID123/signer_links.xml with URI encoded redirect location and return urls for 1 signer_link" do
|
284
|
-
|
284
|
+
@rs.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {:redirect_location => "http://google.com/redirected%20location"}
|
285
285
|
).and_return({'document' => {'signer_links' => {'signer_link' =>
|
286
286
|
{"signer_token" => "fdh89", "name" => "Righty Jones"}
|
287
287
|
}}})
|
288
288
|
|
289
|
-
response =
|
289
|
+
response = @rs.get_document_signer_links_for("GUID123", "http://google.com/redirected location")
|
290
290
|
response.size.should == 1
|
291
|
-
response.include?({"name" => "Righty Jones", "url" => "#{
|
291
|
+
response.include?({"name" => "Righty Jones", "url" => "#{@rs.site}/signatures/embedded?rt=fdh89"}).should be_true
|
292
292
|
end
|
293
293
|
end
|
294
294
|
end
|
@@ -3,22 +3,22 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe RightSignature::OauthConnection do
|
4
4
|
before do
|
5
5
|
@consumer_mock = mock(OAuth::Consumer)
|
6
|
-
@access_token_mock = mock(OAuth::AccessToken)
|
6
|
+
@access_token_mock = mock(OAuth::AccessToken, :token => "token", :secret => "secret")
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "oauth_consumer" do
|
10
10
|
after do
|
11
11
|
# Reset caching of oauth_consumer
|
12
|
-
|
12
|
+
@oauth_connection.instance_variable_set("@oauth_consumer", nil)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should raise error if no configuration is set" do
|
16
|
-
|
17
|
-
lambda{
|
16
|
+
@oauth_connection = RightSignature::OauthConnection.new()
|
17
|
+
lambda{@oauth_connection.oauth_consumer}.should raise_error(Exception, "Please set consumer_key, consumer_secret, access_token, access_secret")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return consumer if consumer_key and consumer_secret is set" do
|
21
|
-
|
21
|
+
@oauth_connection = RightSignature::OauthConnection.new(:consumer_key => "Consumer123", :consumer_secret => "Secret098")
|
22
22
|
OAuth::Consumer.should_receive(:new).with(
|
23
23
|
"Consumer123",
|
24
24
|
"Secret098",
|
@@ -30,33 +30,27 @@ describe RightSignature::OauthConnection do
|
|
30
30
|
:access_token_path =>'/oauth/access_token',
|
31
31
|
:request_token_path=>'/oauth/request_token'
|
32
32
|
}).and_return(@consumer_mock)
|
33
|
-
|
33
|
+
@oauth_connection.oauth_consumer.should == @consumer_mock
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "access_token" do
|
38
|
-
after do
|
39
|
-
# Reset caching of oauth_consumer
|
40
|
-
RightSignature::OauthConnection.instance_variable_set("@access_token", nil)
|
41
|
-
RightSignature::OauthConnection.instance_variable_set("@oauth_consumer", nil)
|
42
|
-
end
|
43
|
-
|
44
38
|
it "should raise error if access_token is not set" do
|
45
|
-
|
46
|
-
lambda{
|
39
|
+
oauth_connection = RightSignature::OauthConnection.new(:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_secret => "Secret098")
|
40
|
+
lambda{oauth_connection.access_token}.should raise_error(Exception, "Please set consumer_key, consumer_secret, access_token, access_secret")
|
47
41
|
end
|
48
42
|
|
49
43
|
it "should raise error if access_secret is not set" do
|
50
|
-
|
51
|
-
lambda{
|
44
|
+
oauth_connection = RightSignature::OauthConnection.new(:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098")
|
45
|
+
lambda{oauth_connection.access_token}.should raise_error(Exception, "Please set consumer_key, consumer_secret, access_token, access_secret")
|
52
46
|
end
|
53
47
|
|
54
48
|
it "should create OAuth access token with credentials" do
|
55
|
-
|
49
|
+
oauth_connection = RightSignature::OauthConnection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123"})
|
56
50
|
OAuth::Consumer.should_receive(:new).and_return(@consumer_mock)
|
57
51
|
OAuth::AccessToken.should_receive(:new).with(@consumer_mock, 'AccessToken098', 'AccessSecret123')
|
58
52
|
|
59
|
-
|
53
|
+
oauth_connection.access_token
|
60
54
|
end
|
61
55
|
|
62
56
|
describe "set_access_token" do
|
@@ -64,8 +58,9 @@ describe RightSignature::OauthConnection do
|
|
64
58
|
OAuth::Consumer.stub(:new).and_return(@consumer_mock)
|
65
59
|
OAuth::AccessToken.should_receive(:new).with(@consumer_mock, "newAToken", "newASecret").and_return(@access_token_mock)
|
66
60
|
|
67
|
-
RightSignature::OauthConnection.
|
68
|
-
|
61
|
+
oauth_connection = RightSignature::OauthConnection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123"})
|
62
|
+
oauth_connection.set_access_token("newAToken","newASecret")
|
63
|
+
oauth_connection.access_token.should == @access_token_mock
|
69
64
|
end
|
70
65
|
end
|
71
66
|
end
|
@@ -75,44 +70,54 @@ describe RightSignature::OauthConnection do
|
|
75
70
|
request_mock = mock(OAuth::RequestToken)
|
76
71
|
OAuth::Consumer.stub(:new).and_return(@consumer_mock)
|
77
72
|
@consumer_mock.should_receive(:get_request_token).and_return(request_mock)
|
78
|
-
|
79
|
-
RightSignature::OauthConnection.
|
73
|
+
|
74
|
+
oauth_connection = RightSignature::OauthConnection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123"})
|
75
|
+
oauth_connection.new_request_token
|
76
|
+
oauth_connection.request_token.should == request_mock
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
83
80
|
describe "generate_access_token" do
|
81
|
+
before do
|
82
|
+
@oauth_connection = RightSignature::OauthConnection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098"})
|
83
|
+
end
|
84
|
+
|
84
85
|
it "should raise error if there is no request_token" do
|
85
86
|
# Reset request_token cache"
|
86
|
-
|
87
|
-
lambda{
|
87
|
+
@oauth_connection.instance_variable_set("@request_token", nil)
|
88
|
+
lambda{@oauth_connection.generate_access_token("verifi123")}.should raise_error(Exception, "Please set request token with new_request_token")
|
88
89
|
end
|
89
90
|
|
90
91
|
it "should get access token from request token with given verifier" do
|
91
92
|
request_token_mock = mock(OAuth::RequestToken)
|
92
93
|
request_token_mock.should_receive(:get_access_token).with({:oauth_verifier => "verifi123"}).and_return(@access_token_mock)
|
93
|
-
|
94
|
+
@oauth_connection.instance_variable_set("@request_token", request_token_mock)
|
94
95
|
|
95
|
-
|
96
|
-
|
96
|
+
@oauth_connection.generate_access_token("verifi123")
|
97
|
+
@oauth_connection.access_token.should == @access_token_mock
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
100
101
|
describe "request" do
|
102
|
+
before do
|
103
|
+
@oauth_connection = RightSignature::OauthConnection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098"})
|
104
|
+
end
|
105
|
+
|
101
106
|
it "should raise error if no configuration is set" do
|
102
|
-
|
103
|
-
lambda{
|
107
|
+
oauth_connection = RightSignature::OauthConnection.new()
|
108
|
+
lambda{oauth_connection.request(:get, "path", {"User-Agent" => 'My own'})}.should raise_error(Exception, "Please set consumer_key, consumer_secret, access_token, access_secret")
|
104
109
|
end
|
105
110
|
|
106
111
|
it "should create GET request with access token and path with custom headers as 3rd argument" do
|
107
112
|
@access_token_mock.should_receive(:get).with('path', {"User-Agent" => 'My own', "Accept"=>"*/*", "content-type"=>"application/xml"})
|
108
|
-
|
109
|
-
|
113
|
+
@oauth_connection.stub(:access_token).and_return(@access_token_mock)
|
114
|
+
@oauth_connection.request(:get, "path", {"User-Agent" => 'My own'})
|
110
115
|
end
|
111
116
|
|
112
117
|
it "should create POST request with access token and path with body as 3rd argument and custom headers as 4th argument" do
|
113
118
|
@access_token_mock.should_receive(:post).with('path', "<template></template>", {"User-Agent" => 'My own', "Accept"=>"*/*", "content-type"=>"application/xml"})
|
114
|
-
|
115
|
-
|
119
|
+
@oauth_connection.stub(:access_token).and_return(@access_token_mock)
|
120
|
+
@oauth_connection.request(:post, "path", "<template></template>", {"User-Agent" => 'My own'})
|
116
121
|
end
|
117
122
|
end
|
118
123
|
|