ruby-trello 0.4.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -8
- data/lib/trello.rb +25 -9
- data/lib/trello/action.rb +5 -5
- data/lib/trello/association_proxy.rb +3 -3
- data/lib/trello/authorization.rb +105 -49
- data/lib/trello/basic_data.rb +48 -4
- data/lib/trello/board.rb +10 -9
- data/lib/trello/card.rb +38 -35
- data/lib/trello/checklist.rb +10 -8
- data/lib/trello/client.rb +98 -29
- data/lib/trello/configuration.rb +68 -0
- data/lib/trello/has_actions.rb +1 -1
- data/lib/trello/list.rb +9 -7
- data/lib/trello/member.rb +3 -3
- data/lib/trello/multi_association.rb +4 -2
- data/lib/trello/notification.rb +8 -8
- data/lib/trello/organization.rb +3 -3
- data/lib/trello/token.rb +4 -4
- data/spec/action_spec.rb +30 -18
- data/spec/basic_auth_policy_spec.rb +1 -0
- data/spec/board_spec.rb +141 -120
- data/spec/card_spec.rb +104 -82
- data/spec/checklist_spec.rb +35 -6
- data/spec/client_spec.rb +56 -19
- data/spec/configuration_spec.rb +114 -0
- data/spec/integration/how_to_authorize_spec.rb +1 -1
- data/spec/list_spec.rb +74 -20
- data/spec/member_spec.rb +37 -23
- data/spec/notification_spec.rb +28 -24
- data/spec/oauth_policy_spec.rb +55 -9
- data/spec/organization_spec.rb +18 -7
- data/spec/spec_helper.rb +5 -0
- data/spec/token_spec.rb +25 -8
- data/spec/trello_spec.rb +73 -0
- metadata +10 -6
data/spec/card_spec.rb
CHANGED
@@ -4,14 +4,30 @@ module Trello
|
|
4
4
|
describe Card do
|
5
5
|
include Helpers
|
6
6
|
|
7
|
+
let(:card) { client.find(:card, 'abcdef123456789123456789') }
|
8
|
+
let(:client) { Client.new }
|
9
|
+
|
7
10
|
before(:each) do
|
8
|
-
|
11
|
+
client.stub(:get).with("/cards/abcdef123456789123456789").
|
9
12
|
and_return JSON.generate(cards_details.first)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "finding" do
|
16
|
+
let(:client) { Trello.client }
|
17
|
+
|
18
|
+
it "delegates to Trello.client#find" do
|
19
|
+
client.should_receive(:find).with(:card, 'abcdef123456789123456789')
|
20
|
+
Card.find('abcdef123456789123456789')
|
21
|
+
end
|
10
22
|
|
11
|
-
|
23
|
+
it "is equivalent to client#find" do
|
24
|
+
Card.find('abcdef123456789123456789').should eq(card)
|
25
|
+
end
|
12
26
|
end
|
13
27
|
|
14
28
|
context "creating" do
|
29
|
+
let(:client) { Trello.client }
|
30
|
+
|
15
31
|
it "creates a new record" do
|
16
32
|
card = Card.new(cards_details.first)
|
17
33
|
card.should be_valid
|
@@ -37,7 +53,7 @@ module Trello
|
|
37
53
|
|
38
54
|
expected_payload = {:name => "Test Card", :desc => nil, :idList => "abcdef123456789123456789"}
|
39
55
|
|
40
|
-
|
56
|
+
client.should_receive(:post).with("/cards", expected_payload).and_return result
|
41
57
|
|
42
58
|
card = Card.create(cards_details.first.merge(payload.merge(:list_id => lists_details.first['id'])))
|
43
59
|
|
@@ -51,110 +67,123 @@ module Trello
|
|
51
67
|
|
52
68
|
payload = {
|
53
69
|
:name => expected_new_name,
|
54
|
-
:desc => "Awesome things are awesome.",
|
55
|
-
:due => nil,
|
56
|
-
:closed => false,
|
57
|
-
:idList => "abcdef123456789123456789",
|
58
|
-
:idBoard => "abcdef123456789123456789",
|
59
|
-
:idMembers => ["abcdef123456789123456789"],
|
60
|
-
:pos => 12
|
61
70
|
}
|
62
71
|
|
63
|
-
|
64
|
-
|
72
|
+
client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
|
73
|
+
|
65
74
|
card.name = expected_new_name
|
66
75
|
card.save
|
67
76
|
end
|
68
77
|
end
|
69
78
|
|
79
|
+
context "deleting" do
|
80
|
+
it "allows a member to be removed from a card" do
|
81
|
+
client.should_receive(:delete).with("/cards/#{card.id}")
|
82
|
+
card.delete
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
70
86
|
context "fields" do
|
71
87
|
it "gets its id" do
|
72
|
-
|
88
|
+
card.id.should_not be_nil
|
73
89
|
end
|
74
90
|
|
75
91
|
it "gets its short id" do
|
76
|
-
|
92
|
+
card.short_id.should_not be_nil
|
77
93
|
end
|
78
94
|
|
79
95
|
it "gets its name" do
|
80
|
-
|
96
|
+
card.name.should_not be_nil
|
81
97
|
end
|
82
98
|
|
83
99
|
it "gets its description" do
|
84
|
-
|
100
|
+
card.description.should_not be_nil
|
85
101
|
end
|
86
102
|
|
87
103
|
it "knows if it is open or closed" do
|
88
|
-
|
104
|
+
card.closed.should_not be_nil
|
89
105
|
end
|
90
106
|
|
91
107
|
it "gets its url" do
|
92
|
-
|
108
|
+
card.url.should_not be_nil
|
93
109
|
end
|
94
110
|
end
|
95
111
|
|
96
112
|
context "actions" do
|
97
113
|
it "asks for all actions by default" do
|
98
|
-
|
99
|
-
|
114
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { :filter => :all }).and_return actions_payload
|
115
|
+
card.actions.count.should be > 0
|
100
116
|
end
|
101
117
|
|
102
118
|
it "allows overriding the filter" do
|
103
|
-
|
104
|
-
|
119
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { :filter => :updateCard }).and_return actions_payload
|
120
|
+
card.actions(:filter => :updateCard).count.should be > 0
|
105
121
|
end
|
106
122
|
end
|
107
123
|
|
108
124
|
context "boards" do
|
109
125
|
it "has a board" do
|
110
|
-
|
111
|
-
|
126
|
+
client.stub(:get).with("/boards/abcdef123456789123456789").and_return JSON.generate(boards_details.first)
|
127
|
+
card.board.should_not be_nil
|
112
128
|
end
|
113
129
|
end
|
114
130
|
|
115
131
|
context "checklists" do
|
116
132
|
it "has a list of checklists" do
|
117
|
-
|
118
|
-
|
133
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/checklists", { :filter => :all }).and_return checklists_payload
|
134
|
+
card.checklists.count.should be > 0
|
119
135
|
end
|
120
136
|
end
|
121
137
|
|
122
138
|
context "list" do
|
123
139
|
it 'has a list' do
|
124
|
-
|
125
|
-
|
140
|
+
client.stub(:get).with("/lists/abcdef123456789123456789").and_return JSON.generate(lists_details.first)
|
141
|
+
card.list.should_not be_nil
|
126
142
|
end
|
127
143
|
|
128
144
|
it 'can be moved to another list' do
|
129
145
|
other_list = stub(:id => '987654321987654321fedcba')
|
130
146
|
payload = {:value => other_list.id}
|
131
|
-
|
132
|
-
|
147
|
+
client.should_receive(:put).with("/cards/abcdef123456789123456789/idList", payload)
|
148
|
+
card.move_to_list(other_list)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should not be moved if new list is identical to old list' do
|
152
|
+
other_list = stub(:id => 'abcdef123456789123456789')
|
153
|
+
payload = {:value => other_list.id}
|
154
|
+
client.should_not_receive(:put)
|
155
|
+
card.move_to_list(other_list)
|
133
156
|
end
|
134
157
|
|
135
158
|
it 'can be moved to another board' do
|
136
159
|
other_board = stub(:id => '987654321987654321fedcba')
|
137
160
|
payload = {:value => other_board.id}
|
138
|
-
|
139
|
-
|
161
|
+
client.should_receive(:put).with("/cards/abcdef123456789123456789/idBoard", payload)
|
162
|
+
card.move_to_board(other_board)
|
140
163
|
end
|
141
164
|
|
142
165
|
it 'can be moved to a list on another board' do
|
143
166
|
other_board = stub(:id => '987654321987654321fedcba')
|
144
167
|
other_list = stub(:id => '987654321987654321aalist')
|
145
168
|
payload = {:value => other_board.id, :idList => other_list.id}
|
146
|
-
|
147
|
-
|
169
|
+
client.should_receive(:put).with("/cards/abcdef123456789123456789/idBoard", payload)
|
170
|
+
card.move_to_board(other_board, other_list)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should not be moved if new board is identical with old board', :focus => true do
|
174
|
+
other_board = stub(:id => 'abcdef123456789123456789')
|
175
|
+
client.should_not_receive(:put)
|
176
|
+
card.move_to_board(other_board)
|
148
177
|
end
|
149
178
|
end
|
150
179
|
|
151
180
|
context "members" do
|
152
181
|
it "has a list of members" do
|
153
|
-
|
154
|
-
|
182
|
+
client.stub(:get).with("/boards/abcdef123456789123456789").and_return JSON.generate(boards_details.first)
|
183
|
+
client.stub(:get).with("/members/abcdef123456789123456789").and_return user_payload
|
155
184
|
|
156
|
-
|
157
|
-
|
185
|
+
card.board.should_not be_nil
|
186
|
+
card.members.should_not be_nil
|
158
187
|
end
|
159
188
|
|
160
189
|
it "allows a member to be added to a card" do
|
@@ -162,32 +191,32 @@ module Trello
|
|
162
191
|
payload = {
|
163
192
|
:value => new_member.id
|
164
193
|
}
|
165
|
-
|
166
|
-
|
194
|
+
client.should_receive(:post).with("/cards/abcdef123456789123456789/members", payload)
|
195
|
+
card.add_member(new_member)
|
167
196
|
end
|
168
197
|
|
169
198
|
it "allows a member to be removed from a card" do
|
170
199
|
existing_member = stub(:id => '4ee7df3ce582acdec80000b2')
|
171
|
-
|
172
|
-
|
200
|
+
client.should_receive(:delete).with("/cards/abcdef123456789123456789/members/#{existing_member.id}")
|
201
|
+
card.remove_member(existing_member)
|
173
202
|
end
|
174
203
|
end
|
175
204
|
|
176
205
|
context "comments" do
|
177
206
|
it "posts a comment" do
|
178
|
-
|
207
|
+
client.should_receive(:post).
|
179
208
|
with("/cards/abcdef123456789123456789/actions/comments", { :text => 'testing' }).
|
180
209
|
and_return JSON.generate(boards_details.first)
|
181
210
|
|
182
|
-
|
211
|
+
card.add_comment "testing"
|
183
212
|
end
|
184
213
|
end
|
185
214
|
|
186
215
|
context "labels" do
|
187
216
|
it "can retrieve labels" do
|
188
|
-
|
217
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/labels").
|
189
218
|
and_return label_payload
|
190
|
-
labels =
|
219
|
+
labels = card.labels
|
191
220
|
labels.size.should == 2
|
192
221
|
|
193
222
|
labels[0].color.should == 'yellow'
|
@@ -198,94 +227,87 @@ module Trello
|
|
198
227
|
end
|
199
228
|
|
200
229
|
it "can add a label" do
|
201
|
-
|
230
|
+
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => 'green' }).
|
202
231
|
and_return "not important"
|
203
|
-
|
204
|
-
|
232
|
+
card.add_label('green')
|
233
|
+
card.errors.should be_empty
|
205
234
|
end
|
206
235
|
|
207
236
|
it "can remove a label" do
|
208
|
-
|
237
|
+
client.stub(:delete).with("/cards/abcdef123456789123456789/labels/green").
|
209
238
|
and_return "not important"
|
210
|
-
|
211
|
-
|
239
|
+
card.remove_label('green')
|
240
|
+
card.errors.should be_empty
|
212
241
|
end
|
213
242
|
|
214
243
|
it "throws an error when trying to add a label with an unknown colour" do
|
215
|
-
|
244
|
+
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => 'green' }).
|
216
245
|
and_return "not important"
|
217
|
-
|
218
|
-
|
246
|
+
card.add_label('mauve')
|
247
|
+
card.errors.full_messages.to_sentence.should == "Label colour 'mauve' does not exist"
|
219
248
|
end
|
220
249
|
|
221
250
|
it "throws an error when trying to remove a label with an unknown colour" do
|
222
|
-
|
251
|
+
client.stub(:delete).with("/cards/abcdef123456789123456789/labels/mauve").
|
223
252
|
and_return "not important"
|
224
|
-
|
225
|
-
|
253
|
+
card.remove_label('mauve')
|
254
|
+
card.errors.full_messages.to_sentence.should == "Label colour 'mauve' does not exist"
|
226
255
|
end
|
227
256
|
end
|
228
257
|
|
229
258
|
context "attachments" do
|
230
259
|
it "can add an attachment" do
|
231
260
|
f = File.new('spec/list_spec.rb', 'r')
|
232
|
-
|
233
|
-
|
261
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/attachments").and_return attachments_payload
|
262
|
+
client.stub(:post).with("/cards/abcdef123456789123456789/attachments",
|
234
263
|
{ :file => f, :name => '' }).
|
235
264
|
and_return "not important"
|
236
265
|
|
237
|
-
|
266
|
+
card.add_attachment(f)
|
238
267
|
|
239
|
-
|
268
|
+
card.errors.should be_empty
|
240
269
|
end
|
241
270
|
|
242
271
|
it "can list the existing attachments" do
|
243
|
-
|
244
|
-
|
272
|
+
client.stub(:get).with("/boards/abcdef123456789123456789").and_return JSON.generate(boards_details.first)
|
273
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/attachments").and_return attachments_payload
|
245
274
|
|
246
|
-
|
247
|
-
|
275
|
+
card.board.should_not be_nil
|
276
|
+
card.attachments.should_not be_nil
|
248
277
|
end
|
249
278
|
|
250
279
|
it "can remove an attachment" do
|
251
|
-
|
280
|
+
client.stub(:delete).with("/cards/abcdef123456789123456789/attachments/abcdef123456789123456789").
|
252
281
|
and_return "not important"
|
253
|
-
|
282
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/attachments").and_return attachments_payload
|
254
283
|
|
255
|
-
|
256
|
-
|
284
|
+
card.remove_attachment(card.attachments.first)
|
285
|
+
card.errors.should be_empty
|
257
286
|
end
|
258
287
|
end
|
259
288
|
|
260
289
|
describe "#closed?" do
|
261
290
|
it "returns the closed attribute" do
|
262
|
-
|
291
|
+
card.closed?.should_not be_true
|
263
292
|
end
|
264
293
|
end
|
265
294
|
|
266
295
|
describe "#close" do
|
267
296
|
it "updates the close attribute to true" do
|
268
|
-
|
269
|
-
|
297
|
+
card.close
|
298
|
+
card.closed.should be_true
|
270
299
|
end
|
271
300
|
end
|
272
301
|
|
273
302
|
describe "#close!" do
|
274
303
|
it "updates the close attribute to true and saves the list" do
|
275
304
|
payload = {
|
276
|
-
:name => @card.name,
|
277
|
-
:desc => "Awesome things are awesome.",
|
278
|
-
:due => nil,
|
279
305
|
:closed => true,
|
280
|
-
:idList => "abcdef123456789123456789",
|
281
|
-
:idBoard => "abcdef123456789123456789",
|
282
|
-
:idMembers => ["abcdef123456789123456789"],
|
283
|
-
:pos => 12
|
284
306
|
}
|
285
307
|
|
286
|
-
|
308
|
+
client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
|
287
309
|
|
288
|
-
|
310
|
+
card.close!
|
289
311
|
end
|
290
312
|
end
|
291
313
|
|
data/spec/checklist_spec.rb
CHANGED
@@ -4,14 +4,30 @@ module Trello
|
|
4
4
|
describe Checklist do
|
5
5
|
include Helpers
|
6
6
|
|
7
|
+
let(:checklist) { client.find(:checklist, 'abcdef123456789123456789') }
|
8
|
+
let(:client) { Client.new }
|
9
|
+
|
7
10
|
before(:each) do
|
8
|
-
|
11
|
+
client.stub(:get).with("/checklists/abcdef123456789123456789").
|
9
12
|
and_return JSON.generate(checklists_details.first)
|
13
|
+
end
|
10
14
|
|
11
|
-
|
15
|
+
context "finding" do
|
16
|
+
let(:client) { Trello.client }
|
17
|
+
|
18
|
+
it "delegates to Trello.client#find" do
|
19
|
+
client.should_receive(:find).with(:checklist, 'abcdef123456789123456789')
|
20
|
+
Checklist.find('abcdef123456789123456789')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is equivalent to client#find" do
|
24
|
+
Checklist.find('abcdef123456789123456789').should eq(checklist)
|
25
|
+
end
|
12
26
|
end
|
13
27
|
|
14
28
|
context "creating" do
|
29
|
+
let(:client) { Trello.client }
|
30
|
+
|
15
31
|
it 'creates a new record and saves it on Trello', :refactor => true do
|
16
32
|
payload = {
|
17
33
|
:name => 'Test Checklist',
|
@@ -22,7 +38,7 @@ module Trello
|
|
22
38
|
|
23
39
|
expected_payload = {:name => "Test Checklist", :idBoard => "abcdef123456789123456789"}
|
24
40
|
|
25
|
-
|
41
|
+
client.should_receive(:post).with("/checklists", expected_payload).and_return result
|
26
42
|
|
27
43
|
checklist = Checklist.create(checklists_details.first.merge(payload.merge(:board_id => boards_details.first['id'])))
|
28
44
|
|
@@ -33,18 +49,31 @@ module Trello
|
|
33
49
|
context "updating" do
|
34
50
|
it "updating name does a put on the correct resource with the correct value" do
|
35
51
|
expected_new_name = "xxx"
|
36
|
-
expected_resource = "/checklists
|
52
|
+
expected_resource = "/checklists/abcdef123456789123456789"
|
37
53
|
payload = {
|
38
54
|
:name => expected_new_name
|
39
55
|
}
|
40
56
|
|
41
57
|
result = JSON.generate(checklists_details.first)
|
42
|
-
|
43
|
-
|
58
|
+
client.should_receive(:put).once.with("/checklists/abcdef123456789123456789", payload).and_return result
|
59
|
+
|
44
60
|
checklist.name = expected_new_name
|
45
61
|
checklist.save
|
46
62
|
end
|
47
63
|
end
|
48
64
|
|
65
|
+
context "board" do
|
66
|
+
it "has a board" do
|
67
|
+
client.stub(:get).with("/boards/abcdef123456789123456789").and_return JSON.generate(boards_details.first)
|
68
|
+
checklist.board.should_not be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "list" do
|
73
|
+
it 'has a list' do
|
74
|
+
client.stub(:get).with("/lists/abcdef123456789123456789").and_return JSON.generate(lists_details.first)
|
75
|
+
checklist.list.should_not be_nil
|
76
|
+
end
|
77
|
+
end
|
49
78
|
end
|
50
79
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -9,19 +9,22 @@ describe Client, "and how it handles authorization" do
|
|
9
9
|
:code => 200,
|
10
10
|
:body => "A fake response body"
|
11
11
|
}
|
12
|
-
|
12
|
+
let(:client) { Client.new }
|
13
|
+
let(:auth_policy) { stub }
|
14
|
+
|
13
15
|
before do
|
14
16
|
TInternet.stub(:execute).and_return fake_ok_response
|
15
|
-
Authorization::AuthPolicy.stub(:
|
17
|
+
Authorization::AuthPolicy.stub(:new).and_return(auth_policy)
|
18
|
+
auth_policy.stub(:authorize) do |request|
|
16
19
|
request
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
it "authorizes before it queries the internet" do
|
21
|
-
|
24
|
+
auth_policy.should_receive(:authorize).once.ordered
|
22
25
|
TInternet.should_receive(:execute).once.ordered
|
23
26
|
|
24
|
-
|
27
|
+
client.get "/xxx"
|
25
28
|
end
|
26
29
|
|
27
30
|
it "queries the internet with expanded earl and query parameters" do
|
@@ -30,7 +33,7 @@ describe Client, "and how it handles authorization" do
|
|
30
33
|
|
31
34
|
TInternet.should_receive(:execute).once.with expected_request
|
32
35
|
|
33
|
-
|
36
|
+
client.get "/xxx", :a => "1", :b => "2"
|
34
37
|
end
|
35
38
|
|
36
39
|
it "encodes parameters" do
|
@@ -39,42 +42,42 @@ describe Client, "and how it handles authorization" do
|
|
39
42
|
|
40
43
|
TInternet.should_receive(:execute).once.with expected_request
|
41
44
|
|
42
|
-
|
45
|
+
client.get "/xxx", :name => "Jazz Kang"
|
43
46
|
end
|
44
47
|
|
45
48
|
it "raises an error when response has non-200 status" do
|
46
49
|
expected_error_message = "An error response"
|
47
|
-
response_with_non_200_status = stub "A fake OK response",
|
50
|
+
response_with_non_200_status = stub "A fake OK response",
|
48
51
|
:code => 404,
|
49
52
|
:body => expected_error_message
|
50
53
|
|
51
54
|
TInternet.stub(:execute).and_return response_with_non_200_status
|
52
55
|
|
53
|
-
lambda{
|
56
|
+
lambda{client.get "/xxx"}.should raise_error expected_error_message
|
54
57
|
end
|
55
58
|
|
56
59
|
it "uses version 1 of the API" do
|
57
60
|
TInternet.should_receive(:execute).once do |request|
|
58
61
|
request.uri.to_s.should =~ /1\//
|
59
62
|
fake_ok_response
|
60
|
-
end
|
63
|
+
end
|
61
64
|
|
62
|
-
|
63
|
-
end
|
65
|
+
client.get "/"
|
66
|
+
end
|
64
67
|
|
65
68
|
it "omits the \"?\" when no parameters" do
|
66
69
|
TInternet.should_receive(:execute).once do |request|
|
67
70
|
request.uri.to_s.should_not =~ /\?$/
|
68
71
|
fake_ok_response
|
69
|
-
end
|
72
|
+
end
|
70
73
|
|
71
|
-
|
74
|
+
client.get "/xxx"
|
72
75
|
end
|
73
76
|
|
74
77
|
it "supports post" do
|
75
78
|
TInternet.should_receive(:execute).once.and_return fake_ok_response
|
76
79
|
|
77
|
-
|
80
|
+
client.post "/xxx", { :phil => "T' north" }
|
78
81
|
end
|
79
82
|
|
80
83
|
it "supplies the body for a post" do
|
@@ -85,7 +88,7 @@ describe Client, "and how it handles authorization" do
|
|
85
88
|
fake_ok_response
|
86
89
|
end
|
87
90
|
|
88
|
-
|
91
|
+
client.post "/xxx", expected_body
|
89
92
|
end
|
90
93
|
|
91
94
|
it "supplies the path for a post" do
|
@@ -96,7 +99,7 @@ describe Client, "and how it handles authorization" do
|
|
96
99
|
fake_ok_response
|
97
100
|
end
|
98
101
|
|
99
|
-
|
102
|
+
client.post "/xxx", {}
|
100
103
|
end
|
101
104
|
|
102
105
|
it "supports put" do
|
@@ -104,7 +107,7 @@ describe Client, "and how it handles authorization" do
|
|
104
107
|
|
105
108
|
TInternet.should_receive(:execute).once.and_return fake_ok_response
|
106
109
|
|
107
|
-
|
110
|
+
client.put "/xxx", { :phil => "T' north" }
|
108
111
|
end
|
109
112
|
|
110
113
|
it "supplies the body for a put" do
|
@@ -115,7 +118,7 @@ describe Client, "and how it handles authorization" do
|
|
115
118
|
fake_ok_response
|
116
119
|
end
|
117
120
|
|
118
|
-
|
121
|
+
client.put "/xxx", expected_body
|
119
122
|
end
|
120
123
|
|
121
124
|
it "supplies the path for a put" do
|
@@ -126,6 +129,40 @@ describe Client, "and how it handles authorization" do
|
|
126
129
|
fake_ok_response
|
127
130
|
end
|
128
131
|
|
129
|
-
|
132
|
+
client.put "/xxx", {}
|
133
|
+
end
|
134
|
+
|
135
|
+
context "initialize" do
|
136
|
+
let(:client) {
|
137
|
+
Client.new(
|
138
|
+
:consumer_key => 'consumer_key',
|
139
|
+
:consumer_secret => 'consumer_secret',
|
140
|
+
:oauth_token => 'oauth_token',
|
141
|
+
:oauth_token_secret => 'oauth_token_secret'
|
142
|
+
)
|
143
|
+
}
|
144
|
+
|
145
|
+
it "is configurable" do
|
146
|
+
client.consumer_key.should eq('consumer_key')
|
147
|
+
client.consumer_secret.should eq('consumer_secret')
|
148
|
+
client.oauth_token.should eq('oauth_token')
|
149
|
+
client.oauth_token_secret.should eq('oauth_token_secret')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "configure" do
|
154
|
+
it "sets key attributes through config block" do
|
155
|
+
client.configure do |config|
|
156
|
+
config.consumer_key = 'consumer_key'
|
157
|
+
config.consumer_secret = 'consumer_secret'
|
158
|
+
config.oauth_token = 'oauth_token'
|
159
|
+
config.oauth_token_secret = 'oauth_token_secret'
|
160
|
+
end
|
161
|
+
|
162
|
+
client.consumer_key.should eq('consumer_key')
|
163
|
+
client.consumer_secret.should eq('consumer_secret')
|
164
|
+
client.oauth_token.should eq('oauth_token')
|
165
|
+
client.oauth_token_secret.should eq('oauth_token_secret')
|
166
|
+
end
|
130
167
|
end
|
131
168
|
end
|