ruby-trello 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/trello/action.rb +17 -5
- data/lib/trello/attachment.rb +15 -0
- data/lib/trello/authorization.rb +9 -9
- data/lib/trello/basic_data.rb +2 -2
- data/lib/trello/board.rb +90 -18
- data/lib/trello/card.rb +127 -18
- data/lib/trello/checklist.rb +29 -8
- data/lib/trello/configuration.rb +8 -8
- data/lib/trello/has_actions.rb +1 -1
- data/lib/trello/item.rb +13 -2
- data/lib/trello/item_state.rb +8 -1
- data/lib/trello/label.rb +5 -0
- data/lib/trello/label_name.rb +8 -3
- data/lib/trello/list.rb +23 -9
- data/lib/trello/member.rb +26 -9
- data/lib/trello/net.rb +5 -5
- data/lib/trello/notification.rb +15 -2
- data/lib/trello/organization.rb +12 -1
- data/lib/trello/token.rb +13 -2
- data/lib/trello/webhook.rb +40 -12
- data/spec/association_spec.rb +5 -5
- data/spec/basic_auth_policy_spec.rb +2 -2
- data/spec/board_spec.rb +45 -14
- data/spec/card_spec.rb +29 -29
- data/spec/checklist_spec.rb +16 -16
- data/spec/client_spec.rb +14 -14
- data/spec/configuration_spec.rb +25 -25
- data/spec/integration/how_to_authorize_spec.rb +5 -5
- data/spec/integration/how_to_use_boards_spec.rb +5 -5
- data/spec/list_spec.rb +10 -10
- data/spec/member_spec.rb +7 -7
- data/spec/oauth_policy_spec.rb +4 -4
- data/spec/organization_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/token_spec.rb +1 -1
- data/spec/webhook_spec.rb +4 -4
- metadata +2 -2
data/spec/association_spec.rb
CHANGED
@@ -3,20 +3,20 @@ require 'spec_helper'
|
|
3
3
|
module Trello
|
4
4
|
describe Association do
|
5
5
|
include Helpers
|
6
|
-
|
6
|
+
|
7
7
|
let(:organization) { client.find(:organization, '4ee7e59ae582acdec8000291') }
|
8
|
-
let(:client) { Client.new(:
|
8
|
+
let(:client) { Client.new(consumer_key: 'xxx') }
|
9
9
|
|
10
10
|
before(:each) do
|
11
11
|
client.stub(:get).with('/organizations/4ee7e59ae582acdec8000291', {}).
|
12
12
|
and_return organization_payload
|
13
13
|
client.stub(:get).with('/organizations/4ee7e59ae582acdec8000291/boards/all').
|
14
|
-
and_return boards_payload
|
14
|
+
and_return boards_payload
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it 'should set the proper client for all associated boards of the organization' do
|
18
18
|
organization.boards.first.client.consumer_key.should == 'xxx'
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
end
|
22
22
|
end
|
@@ -28,7 +28,7 @@ describe BasicAuthPolicy do
|
|
28
28
|
it 'preserves other query parameters' do
|
29
29
|
uri = Addressable::URI.parse('https://xxx/?name=Phil')
|
30
30
|
|
31
|
-
request = Request.new :get, uri, {:
|
31
|
+
request = Request.new :get, uri, {example_header: 'example_value'}
|
32
32
|
|
33
33
|
authorized_request = BasicAuthPolicy.authorize request
|
34
34
|
|
@@ -40,7 +40,7 @@ describe BasicAuthPolicy do
|
|
40
40
|
it 'preserves headers' do
|
41
41
|
uri = Addressable::URI.parse('https://xxx/')
|
42
42
|
|
43
|
-
request = Request.new :get, uri, {:
|
43
|
+
request = Request.new :get, uri, {example_header: 'example_value'}
|
44
44
|
|
45
45
|
authorized_request = BasicAuthPolicy.authorize request
|
46
46
|
|
data/spec/board_spec.rb
CHANGED
@@ -6,6 +6,7 @@ module Trello
|
|
6
6
|
|
7
7
|
let(:board) { client.find(:board, 'abcdef123456789123456789') }
|
8
8
|
let(:client) { Client.new }
|
9
|
+
let(:member) { Member.new(user_payload) }
|
9
10
|
|
10
11
|
before(:each) do
|
11
12
|
client.stub(:get).with("/boards/abcdef123456789123456789", {}).
|
@@ -53,6 +54,10 @@ module Trello
|
|
53
54
|
it "knows if it is closed or open" do
|
54
55
|
board.closed?.should_not be_nil
|
55
56
|
end
|
57
|
+
|
58
|
+
it "knows if it is starred or not" do
|
59
|
+
board.starred?.should_not be_nil
|
60
|
+
end
|
56
61
|
|
57
62
|
it "gets its url" do
|
58
63
|
board.url.should_not be_nil
|
@@ -61,7 +66,7 @@ module Trello
|
|
61
66
|
|
62
67
|
context "actions" do
|
63
68
|
it "has a list of actions" do
|
64
|
-
client.stub(:get).with("/boards/abcdef123456789123456789/actions", {:
|
69
|
+
client.stub(:get).with("/boards/abcdef123456789123456789/actions", {filter: :all}).
|
65
70
|
and_return actions_payload
|
66
71
|
|
67
72
|
board.actions.count.should be > 0
|
@@ -70,7 +75,7 @@ module Trello
|
|
70
75
|
|
71
76
|
context "cards" do
|
72
77
|
it "gets its list of cards" do
|
73
|
-
client.stub(:get).with("/boards/abcdef123456789123456789/cards", { :
|
78
|
+
client.stub(:get).with("/boards/abcdef123456789123456789/cards", { filter: :open }).
|
74
79
|
and_return cards_payload
|
75
80
|
|
76
81
|
board.cards.count.should be > 0
|
@@ -82,7 +87,7 @@ module Trello
|
|
82
87
|
client.stub(:get).with("/boards/abcdef123456789123456789/labelnames").
|
83
88
|
and_return label_name_payload
|
84
89
|
|
85
|
-
board.labels.count.should eq(
|
90
|
+
board.labels.count.should eq(10)
|
86
91
|
end
|
87
92
|
end
|
88
93
|
|
@@ -94,9 +99,28 @@ module Trello
|
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
102
|
+
context "add_member" do
|
103
|
+
it "adds a member to the board as a normal user (default)" do
|
104
|
+
client.stub(:put).with("/boards/abcdef123456789123456789/members/id", type: :normal)
|
105
|
+
board.add_member(member)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "adds a member to the board as an admin" do
|
109
|
+
client.stub(:put).with("/boards/abcdef123456789123456789/members/id", type: :admin)
|
110
|
+
board.add_member(member, :admin)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "remove_member" do
|
115
|
+
it "removes a member from the board" do
|
116
|
+
client.stub(:delete).with("/boards/abcdef123456789123456789/members/id")
|
117
|
+
board.remove_member(member)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
97
121
|
context "lists" do
|
98
122
|
it "has a list of lists" do
|
99
|
-
client.stub(:get).with("/boards/abcdef123456789123456789/lists", hash_including(:
|
123
|
+
client.stub(:get).with("/boards/abcdef123456789123456789/lists", hash_including(filter: :open)).
|
100
124
|
and_return lists_payload
|
101
125
|
|
102
126
|
board.has_lists?.should be true
|
@@ -105,7 +129,7 @@ module Trello
|
|
105
129
|
|
106
130
|
context "members" do
|
107
131
|
it "has a list of members" do
|
108
|
-
client.stub(:get).with("/boards/abcdef123456789123456789/members", hash_including(:
|
132
|
+
client.stub(:get).with("/boards/abcdef123456789123456789/members", hash_including(filter: :all)).
|
109
133
|
and_return JSON.generate([user_details])
|
110
134
|
|
111
135
|
board.members.count.should be > 0
|
@@ -124,6 +148,10 @@ module Trello
|
|
124
148
|
it "is not closed" do
|
125
149
|
expect(board.closed?).not_to be(true)
|
126
150
|
end
|
151
|
+
|
152
|
+
it "is not starred" do
|
153
|
+
expect(board.starred?).not_to be(true)
|
154
|
+
end
|
127
155
|
|
128
156
|
describe "#update_fields" do
|
129
157
|
it "does not set any fields when the fields argument is empty" do
|
@@ -132,6 +160,7 @@ module Trello
|
|
132
160
|
'name' => "name",
|
133
161
|
'desc' => "desc",
|
134
162
|
'closed' => false,
|
163
|
+
'starred' => false,
|
135
164
|
'url' => "url",
|
136
165
|
'idOrganization' => "org_id"
|
137
166
|
}
|
@@ -169,7 +198,7 @@ module Trello
|
|
169
198
|
end
|
170
199
|
|
171
200
|
it "puts all fields except id" do
|
172
|
-
expected_fields = %w{ name description closed idOrganization}.map { |s| s.to_sym }
|
201
|
+
expected_fields = %w{ name description closed starred idOrganization}.map { |s| s.to_sym }
|
173
202
|
|
174
203
|
client.should_receive(:put) do |anything, body|
|
175
204
|
body.keys.should =~ expected_fields
|
@@ -218,12 +247,14 @@ module Trello
|
|
218
247
|
board.name = "new name"
|
219
248
|
board.description = "new description"
|
220
249
|
board.closed = true
|
250
|
+
board.starred = true
|
221
251
|
|
222
252
|
client.should_receive(:put).with("/boards/#{board.id}/", {
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
253
|
+
name: "new name",
|
254
|
+
description: "new description",
|
255
|
+
closed: true,
|
256
|
+
starred: true,
|
257
|
+
idOrganization: nil
|
227
258
|
}).and_return any_board_json
|
228
259
|
board.update!
|
229
260
|
end
|
@@ -239,8 +270,8 @@ module Trello
|
|
239
270
|
end
|
240
271
|
|
241
272
|
it "creates a new board with whatever attributes are supplied " do
|
242
|
-
expected_attributes = { :
|
243
|
-
sent_attributes = { :
|
273
|
+
expected_attributes = { name: "Any new board name", description: "Any new board desription" }
|
274
|
+
sent_attributes = { name: expected_attributes[:name], desc: expected_attributes[:description] }
|
244
275
|
|
245
276
|
client.should_receive(:post).with("/boards", sent_attributes).and_return any_board_json
|
246
277
|
|
@@ -250,13 +281,13 @@ module Trello
|
|
250
281
|
it "posts to the boards collection" do
|
251
282
|
client.should_receive(:post).with("/boards", anything).and_return any_board_json
|
252
283
|
|
253
|
-
Board.create :
|
284
|
+
Board.create xxx: ""
|
254
285
|
end
|
255
286
|
|
256
287
|
it "returns a board" do
|
257
288
|
client.stub(:post).with("/boards", anything).and_return any_board_json
|
258
289
|
|
259
|
-
the_new_board = Board.create :
|
290
|
+
the_new_board = Board.create xxx: ""
|
260
291
|
the_new_board.should be_a Board
|
261
292
|
end
|
262
293
|
|
data/spec/card_spec.rb
CHANGED
@@ -43,20 +43,20 @@ module Trello
|
|
43
43
|
card.should_not be_valid
|
44
44
|
end
|
45
45
|
|
46
|
-
it 'creates a new record and saves it on Trello', :
|
46
|
+
it 'creates a new record and saves it on Trello', refactor: true do
|
47
47
|
payload = {
|
48
|
-
:
|
49
|
-
:
|
48
|
+
name: 'Test Card',
|
49
|
+
desc: nil,
|
50
50
|
}
|
51
51
|
|
52
|
-
result = JSON.generate(cards_details.first.merge(payload.merge(:
|
52
|
+
result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
|
53
53
|
|
54
54
|
expected_payload = {name: "Test Card", desc: nil, idList: "abcdef123456789123456789",
|
55
55
|
idMembers: nil, labels: nil, pos: nil }
|
56
56
|
|
57
57
|
client.should_receive(:post).with("/cards", expected_payload).and_return result
|
58
58
|
|
59
|
-
card = Card.create(cards_details.first.merge(payload.merge(:
|
59
|
+
card = Card.create(cards_details.first.merge(payload.merge(list_id: lists_details.first['id'])))
|
60
60
|
|
61
61
|
card.class.should be Card
|
62
62
|
end
|
@@ -67,7 +67,7 @@ module Trello
|
|
67
67
|
expected_new_name = "xxx"
|
68
68
|
|
69
69
|
payload = {
|
70
|
-
:
|
70
|
+
name: expected_new_name,
|
71
71
|
}
|
72
72
|
|
73
73
|
client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
|
@@ -128,13 +128,13 @@ module Trello
|
|
128
128
|
|
129
129
|
context "actions" do
|
130
130
|
it "asks for all actions by default" do
|
131
|
-
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { :
|
131
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { filter: :all }).and_return actions_payload
|
132
132
|
card.actions.count.should be > 0
|
133
133
|
end
|
134
134
|
|
135
135
|
it "allows overriding the filter" do
|
136
|
-
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { :
|
137
|
-
card.actions(:
|
136
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/actions", { filter: :updateCard }).and_return actions_payload
|
137
|
+
card.actions(filter: :updateCard).count.should be > 0
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -154,7 +154,7 @@ module Trello
|
|
154
154
|
|
155
155
|
context "checklists" do
|
156
156
|
before(:each) do
|
157
|
-
client.stub(:get).with("/cards/abcdef123456789123456789/checklists", { :
|
157
|
+
client.stub(:get).with("/cards/abcdef123456789123456789/checklists", { filter: :all }).and_return checklists_payload
|
158
158
|
end
|
159
159
|
|
160
160
|
it "has a list of checklists" do
|
@@ -174,15 +174,15 @@ module Trello
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'can be moved to another list' do
|
177
|
-
other_list = double(:
|
178
|
-
payload = {:
|
177
|
+
other_list = double(id: '987654321987654321fedcba')
|
178
|
+
payload = {value: other_list.id}
|
179
179
|
client.should_receive(:put).with("/cards/abcdef123456789123456789/idList", payload)
|
180
180
|
card.move_to_list(other_list)
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'should not be moved if new list is identical to old list' do
|
184
|
-
other_list = double(:
|
185
|
-
payload = { :
|
184
|
+
other_list = double(id: 'abcdef123456789123456789')
|
185
|
+
payload = { value: other_list.id }
|
186
186
|
client.should_not_receive(:put)
|
187
187
|
card.move_to_list(other_list)
|
188
188
|
end
|
@@ -194,22 +194,22 @@ module Trello
|
|
194
194
|
end
|
195
195
|
|
196
196
|
it 'can be moved to another board' do
|
197
|
-
other_board = double(:
|
198
|
-
payload = {:
|
197
|
+
other_board = double(id: '987654321987654321fedcba')
|
198
|
+
payload = {value: other_board.id}
|
199
199
|
client.should_receive(:put).with("/cards/abcdef123456789123456789/idBoard", payload)
|
200
200
|
card.move_to_board(other_board)
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'can be moved to a list on another board' do
|
204
|
-
other_board = double(:
|
205
|
-
other_list = double(:
|
206
|
-
payload = {:
|
204
|
+
other_board = double(id: '987654321987654321fedcba')
|
205
|
+
other_list = double(id: '987654321987654321aalist')
|
206
|
+
payload = {value: other_board.id, idList: other_list.id}
|
207
207
|
client.should_receive(:put).with("/cards/abcdef123456789123456789/idBoard", payload)
|
208
208
|
card.move_to_board(other_board, other_list)
|
209
209
|
end
|
210
210
|
|
211
|
-
it 'should not be moved if new board is identical with old board', :
|
212
|
-
other_board = double(:
|
211
|
+
it 'should not be moved if new board is identical with old board', focus: true do
|
212
|
+
other_board = double(id: 'abcdef123456789123456789')
|
213
213
|
client.should_not_receive(:put)
|
214
214
|
card.move_to_board(other_board)
|
215
215
|
end
|
@@ -225,16 +225,16 @@ module Trello
|
|
225
225
|
end
|
226
226
|
|
227
227
|
it "allows a member to be added to a card" do
|
228
|
-
new_member = double(:
|
228
|
+
new_member = double(id: '4ee7df3ce582acdec80000b2')
|
229
229
|
payload = {
|
230
|
-
:
|
230
|
+
value: new_member.id
|
231
231
|
}
|
232
232
|
client.should_receive(:post).with("/cards/abcdef123456789123456789/members", payload)
|
233
233
|
card.add_member(new_member)
|
234
234
|
end
|
235
235
|
|
236
236
|
it "allows a member to be removed from a card" do
|
237
|
-
existing_member = double(:
|
237
|
+
existing_member = double(id: '4ee7df3ce582acdec80000b2')
|
238
238
|
client.should_receive(:delete).with("/cards/abcdef123456789123456789/members/#{existing_member.id}")
|
239
239
|
card.remove_member(existing_member)
|
240
240
|
end
|
@@ -243,7 +243,7 @@ module Trello
|
|
243
243
|
context "comments" do
|
244
244
|
it "posts a comment" do
|
245
245
|
client.should_receive(:post).
|
246
|
-
with("/cards/abcdef123456789123456789/actions/comments", { :
|
246
|
+
with("/cards/abcdef123456789123456789/actions/comments", { text: 'testing' }).
|
247
247
|
and_return JSON.generate(boards_details.first)
|
248
248
|
|
249
249
|
card.add_comment "testing"
|
@@ -265,7 +265,7 @@ module Trello
|
|
265
265
|
end
|
266
266
|
|
267
267
|
it "can add a label" do
|
268
|
-
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :
|
268
|
+
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { value: 'green' }).
|
269
269
|
and_return "not important"
|
270
270
|
card.add_label('green')
|
271
271
|
expect(card.errors).to be_empty
|
@@ -288,7 +288,7 @@ module Trello
|
|
288
288
|
end
|
289
289
|
|
290
290
|
it "throws an error when trying to add a label with an unknown colour" do
|
291
|
-
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :
|
291
|
+
client.stub(:post).with("/cards/abcdef123456789123456789/labels", { value: 'green' }).
|
292
292
|
and_return "not important"
|
293
293
|
card.add_label('mauve')
|
294
294
|
expect(card.errors.full_messages.to_sentence).to eq("Label colour 'mauve' does not exist")
|
@@ -307,7 +307,7 @@ module Trello
|
|
307
307
|
f = File.new('spec/list_spec.rb', 'r')
|
308
308
|
client.stub(:get).with("/cards/abcdef123456789123456789/attachments").and_return attachments_payload
|
309
309
|
client.stub(:post).with("/cards/abcdef123456789123456789/attachments",
|
310
|
-
{ :
|
310
|
+
{ file: f, name: '' }).
|
311
311
|
and_return "not important"
|
312
312
|
|
313
313
|
card.add_attachment(f)
|
@@ -358,7 +358,7 @@ module Trello
|
|
358
358
|
describe "#close!" do
|
359
359
|
it "updates the close attribute to true and saves the list" do
|
360
360
|
payload = {
|
361
|
-
:
|
361
|
+
closed: true,
|
362
362
|
}
|
363
363
|
|
364
364
|
client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
|
data/spec/checklist_spec.rb
CHANGED
@@ -28,19 +28,19 @@ module Trello
|
|
28
28
|
context "creating" do
|
29
29
|
let(:client) { Trello.client }
|
30
30
|
|
31
|
-
it 'creates a new record and saves it on Trello', :
|
31
|
+
it 'creates a new record and saves it on Trello', refactor: true do
|
32
32
|
payload = {
|
33
|
-
:
|
34
|
-
:
|
33
|
+
name: 'Test Checklist',
|
34
|
+
desc: '',
|
35
35
|
}
|
36
36
|
|
37
|
-
result = JSON.generate(checklists_details.first.merge(payload.merge(:
|
37
|
+
result = JSON.generate(checklists_details.first.merge(payload.merge(idBoard: boards_details.first['id'])))
|
38
38
|
|
39
|
-
expected_payload = {:
|
39
|
+
expected_payload = {name: "Test Checklist", idBoard: "abcdef123456789123456789"}
|
40
40
|
|
41
41
|
client.should_receive(:post).with("/checklists", expected_payload).and_return result
|
42
42
|
|
43
|
-
checklist = Checklist.create(checklists_details.first.merge(payload.merge(:
|
43
|
+
checklist = Checklist.create(checklists_details.first.merge(payload.merge(board_id: boards_details.first['id'])))
|
44
44
|
|
45
45
|
checklist.class.should be Checklist
|
46
46
|
end
|
@@ -66,8 +66,8 @@ module Trello
|
|
66
66
|
expected_new_name = "xxx"
|
67
67
|
expected_resource = "/checklists/abcdef123456789123456789"
|
68
68
|
payload = {
|
69
|
-
:
|
70
|
-
:
|
69
|
+
name: expected_new_name,
|
70
|
+
pos: checklist.position
|
71
71
|
}
|
72
72
|
|
73
73
|
result = JSON.generate(checklists_details.first)
|
@@ -81,8 +81,8 @@ module Trello
|
|
81
81
|
expected_new_position = 33
|
82
82
|
expected_resource = "/checklists/abcdef123456789123456789"
|
83
83
|
payload = {
|
84
|
-
:
|
85
|
-
:
|
84
|
+
name: checklist.name,
|
85
|
+
pos: expected_new_position
|
86
86
|
}
|
87
87
|
|
88
88
|
result = JSON.generate(checklists_details.first)
|
@@ -97,14 +97,14 @@ module Trello
|
|
97
97
|
expected_checked = true
|
98
98
|
expected_pos = 9999
|
99
99
|
payload = {
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
100
|
+
name: expected_item_name,
|
101
|
+
checked: expected_checked,
|
102
|
+
pos: expected_pos
|
103
103
|
}
|
104
104
|
result_hash = {
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
105
|
+
name: expected_item_name,
|
106
|
+
state: expected_checked ? 'complete' : 'incomplete',
|
107
|
+
pos: expected_pos
|
108
108
|
}
|
109
109
|
result = JSON.generate(result_hash)
|
110
110
|
client.should_receive(:post).once.with("/checklists/abcdef123456789123456789/checkItems", payload).and_return result
|
data/spec/client_spec.rb
CHANGED
@@ -6,8 +6,8 @@ include Trello::Authorization
|
|
6
6
|
describe Client, "and how it handles authorization" do
|
7
7
|
let (:fake_ok_response) do
|
8
8
|
double "A fake OK response",
|
9
|
-
:
|
10
|
-
:
|
9
|
+
code: 200,
|
10
|
+
body: "A fake response body"
|
11
11
|
end
|
12
12
|
let(:client) { Client.new }
|
13
13
|
let(:auth_policy) { double }
|
@@ -33,7 +33,7 @@ describe Client, "and how it handles authorization" do
|
|
33
33
|
|
34
34
|
TInternet.should_receive(:execute).once.with expected_request
|
35
35
|
|
36
|
-
client.get "/xxx", :
|
36
|
+
client.get "/xxx", a: "1", b: "2"
|
37
37
|
end
|
38
38
|
|
39
39
|
it "encodes parameters" do
|
@@ -42,14 +42,14 @@ describe Client, "and how it handles authorization" do
|
|
42
42
|
|
43
43
|
TInternet.should_receive(:execute).once.with expected_request
|
44
44
|
|
45
|
-
client.get "/xxx", :
|
45
|
+
client.get "/xxx", name: "Jazz Kang"
|
46
46
|
end
|
47
47
|
|
48
48
|
it "raises an error when response has non-200 status" do
|
49
49
|
expected_error_message = "An error response"
|
50
50
|
response_with_non_200_status = double "A fake OK response",
|
51
|
-
:
|
52
|
-
:
|
51
|
+
code: 404,
|
52
|
+
body: expected_error_message
|
53
53
|
|
54
54
|
TInternet.stub(:execute).and_return response_with_non_200_status
|
55
55
|
|
@@ -77,11 +77,11 @@ describe Client, "and how it handles authorization" do
|
|
77
77
|
it "supports post" do
|
78
78
|
TInternet.should_receive(:execute).once.and_return fake_ok_response
|
79
79
|
|
80
|
-
client.post "/xxx", { :
|
80
|
+
client.post "/xxx", { phil: "T' north" }
|
81
81
|
end
|
82
82
|
|
83
83
|
it "supplies the body for a post" do
|
84
|
-
expected_body = { :
|
84
|
+
expected_body = { name: "Phil", nickname: "The Crack Fox" }
|
85
85
|
|
86
86
|
TInternet.should_receive(:execute).once do |request|
|
87
87
|
request.body.should == expected_body
|
@@ -105,11 +105,11 @@ describe Client, "and how it handles authorization" do
|
|
105
105
|
it "supports put" do
|
106
106
|
TInternet.should_receive(:execute).once.and_return fake_ok_response
|
107
107
|
|
108
|
-
client.put "/xxx", { :
|
108
|
+
client.put "/xxx", { phil: "T' north" }
|
109
109
|
end
|
110
110
|
|
111
111
|
it "supplies the body for a put" do
|
112
|
-
expected_body = { :
|
112
|
+
expected_body = { name: "Phil", nickname: "The Crack Fox" }
|
113
113
|
|
114
114
|
TInternet.should_receive(:execute).once do |request|
|
115
115
|
request.body.should == expected_body
|
@@ -133,10 +133,10 @@ describe Client, "and how it handles authorization" do
|
|
133
133
|
context "initialize" do
|
134
134
|
let(:client) do
|
135
135
|
Client.new(
|
136
|
-
:
|
137
|
-
:
|
138
|
-
:
|
139
|
-
:
|
136
|
+
consumer_key: 'consumer_key',
|
137
|
+
consumer_secret: 'consumer_secret',
|
138
|
+
oauth_token: 'oauth_token',
|
139
|
+
oauth_token_secret: 'oauth_token_secret'
|
140
140
|
)
|
141
141
|
end
|
142
142
|
|