ruby-trello 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,7 +47,7 @@ describe "OAuth", :broken => true do
47
47
  OAuthPolicy.token = OAuthCredential.new @access_token_key, nil
48
48
 
49
49
  pending "I would expect this to fail because I have signed with nil secrets" do
50
- lambda{Client.get("/boards/#{@welcome_board}/")}.should raise_error
50
+ -> { Client.get("/boards/#{@welcome_board}/") }.should raise_error
51
51
  end
52
52
  end
53
53
  end
data/spec/item_spec.rb CHANGED
@@ -4,34 +4,34 @@ module Trello
4
4
  describe Item do
5
5
  before(:all) do
6
6
  @detail = {
7
- 'id' => "abcdef123456789123456789",
8
- 'name' => "test item",
9
- 'type' => "check",
10
- 'state' => "complete",
7
+ 'id' => 'abcdef123456789123456789',
8
+ 'name' => 'test item',
9
+ 'type' => 'check',
10
+ 'state' => 'complete',
11
11
  'pos' => 0
12
12
  }
13
13
 
14
14
  @item = Item.new(@detail)
15
15
  end
16
16
 
17
- it "gets its id" do
17
+ it 'gets its id' do
18
18
  @item.id.should == @detail['id']
19
19
  end
20
20
 
21
- it "gets its name" do
21
+ it 'gets its name' do
22
22
  @item.name.should == @detail['name']
23
23
  end
24
24
 
25
- it "knows its type" do
25
+ it 'knows its type' do
26
26
  @item.type.should == @detail['type']
27
27
  end
28
28
 
29
- it "knows its state" do
29
+ it 'knows its state' do
30
30
  @item.state.should == @detail['state']
31
31
  end
32
32
 
33
- it "knows its pos" do
33
+ it 'knows its pos' do
34
34
  @item.pos.should == @detail['pos']
35
35
  end
36
36
  end
37
- end
37
+ end
data/spec/list_spec.rb CHANGED
@@ -4,31 +4,31 @@ module Trello
4
4
  describe List do
5
5
  include Helpers
6
6
 
7
- let(:list) { client.find(:list, "abcdef123456789123456789") }
7
+ let(:list) { client.find(:list, 'abcdef123456789123456789') }
8
8
  let(:client) { Client.new }
9
9
 
10
10
  before(:each) do
11
- client.stub(:get).with("/lists/abcdef123456789123456789", {}).and_return JSON.generate(lists_details.first)
12
- client.stub(:get).with("/boards/abcdef123456789123456789", {}).and_return JSON.generate(boards_details.first)
11
+ client.stub(:get).with('/lists/abcdef123456789123456789', {}).and_return JSON.generate(lists_details.first)
12
+ client.stub(:get).with('/boards/abcdef123456789123456789', {}).and_return JSON.generate(boards_details.first)
13
13
  end
14
14
 
15
- context "finding" do
15
+ context 'finding' do
16
16
  let(:client) { Trello.client }
17
17
 
18
- it "delegates to client#find" do
18
+ it 'delegates to client#find' do
19
19
  client.should_receive(:find).with(:list, 'abcdef123456789123456789', {})
20
20
  List.find('abcdef123456789123456789')
21
21
  end
22
22
 
23
- it "is equivalent to client#find" do
23
+ it 'is equivalent to client#find' do
24
24
  List.find('abcdef123456789123456789').should eq(list)
25
25
  end
26
26
  end
27
27
 
28
- context "creating" do
28
+ context 'creating' do
29
29
  let(:client) { Trello.client }
30
30
 
31
- it "creates a new record" do
31
+ it 'creates a new record' do
32
32
  list = List.new(lists_details.first)
33
33
  list.should be_valid
34
34
  end
@@ -51,9 +51,9 @@ module Trello
51
51
 
52
52
  result = JSON.generate(payload)
53
53
 
54
- expected_payload = {:name => "Test List", :closed => false, :idBoard => "abcdef123456789123456789"}
54
+ expected_payload = {:name => 'Test List', :closed => false, :idBoard => 'abcdef123456789123456789'}
55
55
 
56
- client.should_receive(:post).with("/lists", expected_payload).and_return result
56
+ client.should_receive(:post).with('/lists', expected_payload).and_return result
57
57
 
58
58
  list = List.create(payload)
59
59
 
@@ -61,73 +61,73 @@ module Trello
61
61
  end
62
62
  end
63
63
 
64
- context "updating" do
65
- it "updating name does a put on the correct resource with the correct value" do
66
- expected_new_name = "xxx"
64
+ context 'updating' do
65
+ it 'updating name does a put on the correct resource with the correct value' do
66
+ expected_new_name = 'xxx'
67
67
 
68
68
  payload = {
69
69
  :name => expected_new_name,
70
70
  :closed => false
71
71
  }
72
72
 
73
- client.should_receive(:put).once.with("/lists/abcdef123456789123456789", payload)
73
+ client.should_receive(:put).once.with('/lists/abcdef123456789123456789', payload)
74
74
  list.name = expected_new_name
75
75
  list.save
76
76
  end
77
77
  end
78
78
 
79
- context "fields" do
80
- it "gets its id" do
79
+ context 'fields' do
80
+ it 'gets its id' do
81
81
  list.id.should == lists_details.first['id']
82
82
  end
83
83
 
84
- it "gets its name" do
84
+ it 'gets its name' do
85
85
  list.name.should == lists_details.first['name']
86
86
  end
87
87
 
88
- it "knows if it is open or closed" do
88
+ it 'knows if it is open or closed' do
89
89
  list.closed.should == lists_details.first['closed']
90
90
  end
91
91
 
92
- it "has a board" do
92
+ it 'has a board' do
93
93
  list.board.should == Board.new(boards_details.first)
94
94
  end
95
95
 
96
- it "gets its position" do
96
+ it 'gets its position' do
97
97
  list.pos.should == lists_details.first['pos']
98
98
  end
99
99
  end
100
100
 
101
- context "actions" do
102
- it "has a list of actions" do
103
- client.stub(:get).with("/lists/abcdef123456789123456789/actions", { :filter => :all }).and_return actions_payload
101
+ context 'actions' do
102
+ it 'has a list of actions' do
103
+ client.stub(:get).with('/lists/abcdef123456789123456789/actions', { :filter => :all }).and_return actions_payload
104
104
  list.actions.count.should be > 0
105
105
  end
106
106
  end
107
107
 
108
- context "cards" do
109
- it "has a list of cards" do
110
- client.stub(:get).with("/lists/abcdef123456789123456789/cards", { :filter => :open }).and_return cards_payload
108
+ context 'cards' do
109
+ it 'has a list of cards' do
110
+ client.stub(:get).with('/lists/abcdef123456789123456789/cards', { :filter => :open }).and_return cards_payload
111
111
  list.cards.count.should be > 0
112
112
  end
113
113
  end
114
114
 
115
- describe "#closed?" do
116
- it "returns the closed attribute" do
115
+ describe '#closed?' do
116
+ it 'returns the closed attribute' do
117
117
  list.closed?.should_not be_true
118
118
  end
119
119
  end
120
120
 
121
- describe "#close" do
122
- it "updates the close attribute to true" do
121
+ describe '#close' do
122
+ it 'updates the close attribute to true' do
123
123
  list.close
124
124
  list.closed.should be_true
125
125
  end
126
126
  end
127
127
 
128
- describe "#close!" do
129
- it "updates the close attribute to true and saves the list" do
130
- client.should_receive(:put).once.with("/lists/abcdef123456789123456789", {
128
+ describe '#close!' do
129
+ it 'updates the close attribute to true and saves the list' do
130
+ client.should_receive(:put).once.with('/lists/abcdef123456789123456789', {
131
131
  :name => list.name,
132
132
  :closed => true
133
133
  })
data/spec/member_spec.rb CHANGED
@@ -10,104 +10,104 @@ module Trello
10
10
  let(:client) { Client.new }
11
11
 
12
12
  before(:each) do
13
- client.stub(:get).with("/members/abcdef123456789012345678", {}).and_return user_payload
13
+ client.stub(:get).with('/members/abcdef123456789012345678', {}).and_return user_payload
14
14
  end
15
15
 
16
- context "finding" do
16
+ context 'finding' do
17
17
  let(:client) { Trello.client }
18
18
 
19
- it "delegates to Trello.client#find" do
19
+ it 'delegates to Trello.client#find' do
20
20
  client.should_receive(:find).with(:member, 'abcdef123456789012345678', {})
21
21
  Member.find('abcdef123456789012345678')
22
22
  end
23
23
 
24
- it "is equivalent to client#find" do
24
+ it 'is equivalent to client#find' do
25
25
  Member.find('abcdef123456789012345678').should eq(member)
26
26
  end
27
27
  end
28
28
 
29
- context "actions" do
30
- it "retrieves a list of actions", :refactor => true do
31
- client.stub(:get).with("/members/abcdef123456789012345678/actions", { :filter => :all }).and_return actions_payload
29
+ context 'actions' do
30
+ it 'retrieves a list of actions', :refactor => true do
31
+ client.stub(:get).with('/members/abcdef123456789012345678/actions', { :filter => :all }).and_return actions_payload
32
32
  member.actions.count.should be > 0
33
33
  end
34
34
  end
35
35
 
36
- context "boards" do
37
- it "has a list of boards" do
38
- client.stub(:get).with("/members/abcdef123456789012345678/boards", { :filter => :all }).and_return boards_payload
36
+ context 'boards' do
37
+ it 'has a list of boards' do
38
+ client.stub(:get).with('/members/abcdef123456789012345678/boards', { :filter => :all }).and_return boards_payload
39
39
  boards = member.boards
40
40
  boards.count.should be > 0
41
41
  end
42
42
  end
43
43
 
44
- context "cards" do
45
- it "has a list of cards" do
46
- client.stub(:get).with("/members/abcdef123456789012345678/cards", { :filter => :open }).and_return cards_payload
44
+ context 'cards' do
45
+ it 'has a list of cards' do
46
+ client.stub(:get).with('/members/abcdef123456789012345678/cards', { :filter => :open }).and_return cards_payload
47
47
  cards = member.cards
48
48
  cards.count.should be > 0
49
49
  end
50
50
  end
51
51
 
52
- context "organizations" do
53
- it "has a list of organizations" do
54
- client.stub(:get).with("/members/abcdef123456789012345678/organizations", { :filter => :all }).and_return orgs_payload
52
+ context 'organizations' do
53
+ it 'has a list of organizations' do
54
+ client.stub(:get).with('/members/abcdef123456789012345678/organizations', { :filter => :all }).and_return orgs_payload
55
55
  orgs = member.organizations
56
56
  orgs.count.should be > 0
57
57
  end
58
58
  end
59
59
 
60
- context "notifications" do
61
- it "has a list of notifications" do
62
- client.stub(:get).with("/members/abcdef123456789012345678/notifications", {}).and_return "[" << notification_payload << "]"
60
+ context 'notifications' do
61
+ it 'has a list of notifications' do
62
+ client.stub(:get).with('/members/abcdef123456789012345678/notifications', {}).and_return '[' << notification_payload << ']'
63
63
  member.notifications.count.should be 1
64
64
  end
65
65
  end
66
66
 
67
- context "personal" do
68
- it "gets the members bio" do
67
+ context 'personal' do
68
+ it 'gets the members bio' do
69
69
  member.bio.should == user_details['bio']
70
70
  end
71
71
 
72
- it "gets the full name" do
72
+ it 'gets the full name' do
73
73
  member.full_name.should == user_details['fullName']
74
74
  end
75
75
 
76
- it "gets the avatar id" do
76
+ it 'gets the avatar id' do
77
77
  member.avatar_id.should == user_details['avatarHash']
78
78
  end
79
79
 
80
- it "returns a valid url for the avatar" do
81
- member.avatar_url(:size => :large).should == "https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/170.png"
82
- member.avatar_url(:size => :small).should == "https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/30.png"
80
+ it 'returns a valid url for the avatar' do
81
+ member.avatar_url(:size => :large).should == 'https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/170.png'
82
+ member.avatar_url(:size => :small).should == 'https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/30.png'
83
83
  end
84
84
 
85
- it "gets the url" do
85
+ it 'gets the url' do
86
86
  member.url.should == user_details['url']
87
87
  end
88
88
 
89
- it "gets the username" do
89
+ it 'gets the username' do
90
90
  member.username.should == user_details['username']
91
91
  end
92
92
 
93
- it "gets the email" do
93
+ it 'gets the email' do
94
94
  member.email.should == user_details['email']
95
95
  end
96
96
 
97
- it "gets the initials" do
97
+ it 'gets the initials' do
98
98
  member.initials.should == user_details['initials']
99
99
  end
100
100
  end
101
101
 
102
- context "modification" do
103
- it "lets us know a field has changed without committing it" do
102
+ context 'modification' do
103
+ it 'lets us know a field has changed without committing it' do
104
104
  member.changed?.should be_false
105
- member.bio = "New and amazing"
105
+ member.bio = 'New and amazing'
106
106
  member.changed?.should be_true
107
107
  end
108
108
 
109
- it "doesn't understand the #id= method" do
110
- lambda { member.id = "42" }.should raise_error NoMethodError
109
+ it 'does not understand the #id= method' do
110
+ -> { member.id = '42' }.should raise_error NoMethodError
111
111
  end
112
112
  end
113
113
  end
@@ -1,22 +1,22 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  include Trello
4
4
  include Trello::Authorization
5
5
 
6
6
  describe OAuthPolicy do
7
7
  before do
8
- OAuthPolicy.consumer_credential = OAuthCredential.new "xxx", "xxx"
8
+ OAuthPolicy.consumer_credential = OAuthCredential.new 'xxx', 'xxx'
9
9
  OAuthPolicy.token = nil
10
10
  end
11
11
 
12
- describe "#consumer_credential" do
13
- it "uses class setting if available" do
12
+ describe '#consumer_credential' do
13
+ it 'uses class setting if available' do
14
14
  policy = OAuthPolicy.new
15
15
  policy.consumer_credential.key.should eq('xxx')
16
16
  policy.consumer_credential.secret.should eq('xxx')
17
17
  end
18
18
 
19
- it "is built from given consumer_key and consumer_secret" do
19
+ it 'is built from given consumer_key and consumer_secret' do
20
20
  policy = OAuthPolicy.new(
21
21
  :consumer_key => 'consumer_key',
22
22
  :consumer_secret => 'consumer_secret'
@@ -25,22 +25,22 @@ describe OAuthPolicy do
25
25
  policy.consumer_credential.secret.should eq('consumer_secret')
26
26
  end
27
27
 
28
- it "is nil if none supplied to class" do
28
+ it 'is nil if none supplied to class' do
29
29
  OAuthPolicy.consumer_credential = nil
30
30
  policy = OAuthPolicy.new
31
31
  policy.consumer_credential.should be_nil
32
32
  end
33
33
  end
34
34
 
35
- describe "#token" do
36
- it "uses class setting if available" do
37
- OAuthPolicy.token = OAuthCredential.new "xxx", "xxx"
35
+ describe '#token' do
36
+ it 'uses class setting if available' do
37
+ OAuthPolicy.token = OAuthCredential.new 'xxx', 'xxx'
38
38
  policy = OAuthPolicy.new
39
39
  policy.token.key.should eq('xxx')
40
40
  policy.token.secret.should eq('xxx')
41
41
  end
42
42
 
43
- it "is built from given oauth_token and oauth_token_secret" do
43
+ it 'is built from given oauth_token and oauth_token_secret' do
44
44
  policy = OAuthPolicy.new(
45
45
  :oauth_token => 'oauth_token',
46
46
  :oauth_token_secret => 'oauth_token_secret'
@@ -49,91 +49,91 @@ describe OAuthPolicy do
49
49
  policy.token.secret.should eq('oauth_token_secret')
50
50
  end
51
51
 
52
- it "is an empty token if no oauth credentials supplied" do
52
+ it 'is an empty token if no oauth credentials supplied' do
53
53
  policy = OAuthPolicy.new
54
54
  policy.token.should be_nil
55
55
  end
56
56
  end
57
57
 
58
- context "2-legged" do
59
- it "adds an authorization header" do
60
- uri = Addressable::URI.parse("https://xxx/")
58
+ context '2-legged' do
59
+ it 'adds an authorization header' do
60
+ uri = Addressable::URI.parse('https://xxx/')
61
61
 
62
62
  request = Request.new :get, uri
63
63
 
64
- OAuthPolicy.token = OAuthCredential.new "token", nil
64
+ OAuthPolicy.token = OAuthCredential.new 'token', nil
65
65
 
66
66
  authorized_request = OAuthPolicy.authorize request
67
67
 
68
- authorized_request.headers.keys.should include "Authorization"
68
+ authorized_request.headers.keys.should include 'Authorization'
69
69
  end
70
70
 
71
- it "preserves query parameters" do
72
- uri = Addressable::URI.parse("https://xxx/?name=Riccardo")
71
+ it 'preserves query parameters' do
72
+ uri = Addressable::URI.parse('https://xxx/?name=Riccardo')
73
73
  request = Request.new :get, uri
74
74
 
75
- Clock.stub(:timestamp).and_return "1327048592"
76
- Nonce.stub(:next).and_return "b94ff2bf7f0a5e87a326064ae1dbb18f"
77
- OAuthPolicy.consumer_credential = OAuthCredential.new "consumer_key", "consumer_secret"
78
- OAuthPolicy.token = OAuthCredential.new "token", nil
75
+ Clock.stub(:timestamp).and_return '1327048592'
76
+ Nonce.stub(:next).and_return 'b94ff2bf7f0a5e87a326064ae1dbb18f'
77
+ OAuthPolicy.consumer_credential = OAuthCredential.new 'consumer_key', 'consumer_secret'
78
+ OAuthPolicy.token = OAuthCredential.new 'token', nil
79
79
 
80
80
  authorized_request = OAuthPolicy.authorize request
81
81
 
82
82
  the_query_parameters = Addressable::URI.parse(authorized_request.uri).query_values
83
- the_query_parameters.should == {"name" => "Riccardo"}
83
+ the_query_parameters.should == {'name' => 'Riccardo'}
84
84
  end
85
85
 
86
- it "adds the correct signature as part of authorization header" do
87
- Clock.stub(:timestamp).and_return "1327048592"
88
- Nonce.stub(:next).and_return "b94ff2bf7f0a5e87a326064ae1dbb18f"
86
+ it 'adds the correct signature as part of authorization header' do
87
+ Clock.stub(:timestamp).and_return '1327048592'
88
+ Nonce.stub(:next).and_return 'b94ff2bf7f0a5e87a326064ae1dbb18f'
89
89
 
90
- OAuthPolicy.consumer_credential = OAuthCredential.new "consumer_key", "consumer_secret"
91
- OAuthPolicy.token = OAuthCredential.new "token", nil
90
+ OAuthPolicy.consumer_credential = OAuthCredential.new 'consumer_key', 'consumer_secret'
91
+ OAuthPolicy.token = OAuthCredential.new 'token', nil
92
92
 
93
- request = Request.new :get, Addressable::URI.parse("http://xxx/")
93
+ request = Request.new :get, Addressable::URI.parse('http://xxx/')
94
94
 
95
95
  authorized_request = OAuthPolicy.authorize request
96
96
 
97
- authorized_request.headers["Authorization"].should =~ /oauth_signature="TVNk%2FCs03FHqutDUqn05%2FDkvVek%3D"/
97
+ authorized_request.headers['Authorization'].should =~ /oauth_signature="TVNk%2FCs03FHqutDUqn05%2FDkvVek%3D"/
98
98
  end
99
99
 
100
- it "adds correct signature for uri with parameters" do
101
- Clock.stub(:timestamp).and_return "1327351010"
102
- Nonce.stub(:next).and_return "f5474aaf44ca84df0b09870044f91c69"
100
+ it 'adds correct signature for uri with parameters' do
101
+ Clock.stub(:timestamp).and_return '1327351010'
102
+ Nonce.stub(:next).and_return 'f5474aaf44ca84df0b09870044f91c69'
103
103
 
104
- OAuthPolicy.consumer_credential = OAuthCredential.new "consumer_key", "consumer_secret"
105
- OAuthPolicy.token = OAuthCredential.new "token", nil
104
+ OAuthPolicy.consumer_credential = OAuthCredential.new 'consumer_key', 'consumer_secret'
105
+ OAuthPolicy.token = OAuthCredential.new 'token', nil
106
106
 
107
- request = Request.new :get, Addressable::URI.parse("http://xxx/?a=b")
107
+ request = Request.new :get, Addressable::URI.parse('http://xxx/?a=b')
108
108
 
109
109
  authorized_request = OAuthPolicy.authorize request
110
110
 
111
- authorized_request.headers["Authorization"].should =~ /oauth_signature="DprU1bdbNdJQ40UhD4n7wRR9jts%3D"/
111
+ authorized_request.headers['Authorization'].should =~ /oauth_signature="DprU1bdbNdJQ40UhD4n7wRR9jts%3D"/
112
112
  end
113
113
 
114
- it "fails if consumer_credential is unset" do
114
+ it 'fails if consumer_credential is unset' do
115
115
  OAuthPolicy.consumer_credential = nil
116
116
 
117
- request = Request.new :get, Addressable::URI.parse("http://xxx/")
117
+ request = Request.new :get, Addressable::URI.parse('http://xxx/')
118
118
 
119
- lambda{OAuthPolicy.authorize request}.should raise_error "The consumer_credential has not been supplied."
119
+ -> { OAuthPolicy.authorize request }.should raise_error 'The consumer_credential has not been supplied.'
120
120
  end
121
121
 
122
- it "can sign with token" do
123
- Clock.stub(:timestamp).and_return "1327360530"
124
- Nonce.stub(:next).and_return "4f610cb28e7aa8711558de5234af1f0e"
122
+ it 'can sign with token' do
123
+ Clock.stub(:timestamp).and_return '1327360530'
124
+ Nonce.stub(:next).and_return '4f610cb28e7aa8711558de5234af1f0e'
125
125
 
126
- OAuthPolicy.consumer_credential = OAuthCredential.new "consumer_key", "consumer_secret"
127
- OAuthPolicy.token = OAuthCredential.new "token_key", "token_secret"
126
+ OAuthPolicy.consumer_credential = OAuthCredential.new 'consumer_key', 'consumer_secret'
127
+ OAuthPolicy.token = OAuthCredential.new 'token_key', 'token_secret'
128
128
 
129
- request = Request.new :get, Addressable::URI.parse("http://xxx/")
129
+ request = Request.new :get, Addressable::URI.parse('http://xxx/')
130
130
 
131
131
  authorized_request = OAuthPolicy.authorize request
132
132
 
133
- authorized_request.headers["Authorization"].should =~ /oauth_signature="1Boj4fo6KiXA4xGD%2BKF5QOD36PI%3D"/
133
+ authorized_request.headers['Authorization'].should =~ /oauth_signature="1Boj4fo6KiXA4xGD%2BKF5QOD36PI%3D"/
134
134
  end
135
135
 
136
- it "adds correct signature for https uri"
137
- it "adds correct signature for verbs other than get"
136
+ it 'adds correct signature for https uri'
137
+ it 'adds correct signature for verbs other than get'
138
138
  end
139
139
  end