/
trello_spec.rb
73 lines (60 loc) · 2.33 KB
/
trello_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'spec_helper'
include Trello
include Trello::Authorization
describe Trello do
describe "self.configure" do
it "builds auth policy client uses to make requests" do
Trello.configure do |config|
config.developer_public_key = 'developer_public_key'
config.member_token = 'member_token'
end
TInternet.stub(:execute)
Trello.auth_policy.should_receive(:authorize)
Trello.client.get(:member, params = {})
end
it "configures basic auth policy" do
Trello.configure do |config|
config.developer_public_key = 'developer_public_key'
config.member_token = 'member_token'
end
auth_policy = Trello.auth_policy
auth_policy.should be_a(BasicAuthPolicy)
auth_policy.developer_public_key.should eq('developer_public_key')
auth_policy.member_token.should eq('member_token')
end
context "oauth" do
before do
Trello.configure do |config|
config.consumer_key = 'consumer_key'
config.consumer_secret = 'consumer_secret'
config.oauth_token = 'oauth_token'
config.oauth_token_secret = 'oauth_token_secret'
end
end
it "configures oauth policy" do
auth_policy = Trello.auth_policy
auth_policy.should be_a(OAuthPolicy)
auth_policy.consumer_key.should eq('consumer_key')
auth_policy.consumer_secret.should eq('consumer_secret')
auth_policy.oauth_token.should eq('oauth_token')
auth_policy.oauth_token_secret.should eq('oauth_token_secret')
end
it "updates auth policy configuration" do
auth_policy = Trello.auth_policy
auth_policy.consumer_key.should eq('consumer_key')
Trello.configure do |config|
config.consumer_key = 'new_consumer_key'
config.consumer_secret = 'new_consumer_secret'
config.oauth_token = 'new_oauth_token'
config.oauth_token_secret = nil
end
auth_policy = Trello.auth_policy
auth_policy.should be_a(OAuthPolicy)
auth_policy.consumer_key.should eq('new_consumer_key')
auth_policy.consumer_secret.should eq('new_consumer_secret')
auth_policy.oauth_token.should eq('new_oauth_token')
auth_policy.oauth_token_secret.should be_nil
end
end
end
end