jira-ruby 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,85 +14,85 @@ describe JIRA::Client do
14
14
 
15
15
  let(:response) do
16
16
  response = double("response")
17
- response.stub(:kind_of?).with(Net::HTTPSuccess).and_return(true)
17
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
18
18
  response
19
19
  end
20
20
 
21
21
  let(:headers) { {'Accept' => 'application/json'} }
22
22
  let(:content_type_header) { {'Content-Type' => 'application/json'} }
23
23
  let(:merged_headers) { headers.merge(content_type_header) }
24
-
24
+
25
25
  it "creates an instance" do
26
- clients.each {|client| client.class.should == JIRA::Client }
26
+ clients.each {|client| expect(client.class).to eq(JIRA::Client) }
27
27
  end
28
28
 
29
29
  it "allows the overriding of some options" do
30
30
  client = JIRA::Client.new({:consumer_key => 'foo', :consumer_secret => 'bar', :site => 'http://foo.com/'})
31
- client.options[:site].should == 'http://foo.com/'
32
- JIRA::Client::DEFAULT_OPTIONS[:site].should_not == 'http://foo.com/'
31
+ expect(client.options[:site]).to eq('http://foo.com/')
32
+ expect(JIRA::Client::DEFAULT_OPTIONS[:site]).not_to eq('http://foo.com/')
33
33
  end
34
34
 
35
35
  it "prepends the context path to the rest base path" do
36
36
  options = [:rest_base_path]
37
37
  defaults = JIRA::Client::DEFAULT_OPTIONS
38
38
  options.each do |key|
39
- clients.each { |client| client.options[key].should == defaults[:context_path] + defaults[key] }
39
+ clients.each { |client| expect(client.options[key]).to eq(defaults[:context_path] + defaults[key]) }
40
40
  end
41
41
  end
42
42
 
43
43
  # To avoid having to validate options after initialisation, e.g. setting
44
44
  # client.options[:invalid] = 'foo'
45
45
  it "freezes the options" do
46
- clients.each { |client| client.options.should be_frozen }
46
+ clients.each { |client| expect(client.options).to be_frozen }
47
47
  end
48
48
 
49
49
  it "merges headers" do
50
- clients.each { |client| client.send(:merge_default_headers, {}).should == {'Accept' => 'application/json'} }
50
+ clients.each { |client| expect(client.send(:merge_default_headers, {})).to eq({'Accept' => 'application/json'}) }
51
51
  end
52
52
 
53
53
  describe "creates instances of request clients" do
54
54
  specify "that are of the correct class" do
55
- oauth_client.request_client.class.should == JIRA::OauthClient
56
- basic_client.request_client.class.should == JIRA::HttpClient
55
+ expect(oauth_client.request_client.class).to eq(JIRA::OauthClient)
56
+ expect(basic_client.request_client.class).to eq(JIRA::HttpClient)
57
57
  end
58
58
 
59
59
  specify "which have a corresponding auth type option" do
60
- oauth_client.options[:auth_type].should == :oauth
61
- basic_client.options[:auth_type].should == :basic
60
+ expect(oauth_client.options[:auth_type]).to eq(:oauth)
61
+ expect(basic_client.options[:auth_type]).to eq(:basic)
62
62
  end
63
63
 
64
64
  describe "like oauth" do
65
65
 
66
66
  it "allows setting an access token" do
67
67
  token = double()
68
- OAuth::AccessToken.should_receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
68
+ expect(OAuth::AccessToken).to receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
69
69
  access_token = oauth_client.set_access_token('foo', 'bar')
70
70
 
71
- access_token.should == token
72
- oauth_client.access_token.should == token
71
+ expect(access_token).to eq(token)
72
+ expect(oauth_client.access_token).to eq(token)
73
73
  end
74
74
 
75
75
  it "allows initializing the access token" do
76
76
  request_token = OAuth::RequestToken.new(oauth_client.consumer)
77
- oauth_client.consumer.stub(:get_request_token => request_token)
77
+ allow(oauth_client.consumer).to receive(:get_request_token).and_return(request_token)
78
78
  mock_access_token = double()
79
- request_token.should_receive(:get_access_token).with(:oauth_verifier => 'abc123').and_return(mock_access_token)
79
+ expect(request_token).to receive(:get_access_token).with(:oauth_verifier => 'abc123').and_return(mock_access_token)
80
80
  oauth_client.init_access_token(:oauth_verifier => 'abc123')
81
- oauth_client.access_token.should == mock_access_token
81
+ expect(oauth_client.access_token).to eq(mock_access_token)
82
82
  end
83
83
 
84
84
  specify "that has specific default options" do
85
85
  options = [:signature_method, :private_key_file]
86
86
  options.each do |key|
87
- oauth_client.options[key].should == JIRA::Client::DEFAULT_OPTIONS[key]
87
+ expect(oauth_client.options[key]).to eq(JIRA::Client::DEFAULT_OPTIONS[key])
88
88
  end
89
89
  end
90
90
  end
91
91
 
92
92
  describe "like basic http" do
93
93
  it "sets the username and password" do
94
- basic_client.options[:username].should == 'foo'
95
- basic_client.options[:password].should == 'bar'
94
+ expect(basic_client.options[:username]).to eq('foo')
95
+ expect(basic_client.options[:password]).to eq('bar')
96
96
  end
97
97
  end
98
98
  end
@@ -104,16 +104,16 @@ describe JIRA::Client do
104
104
 
105
105
  specify "that merge default headers" do
106
106
  # stubbed response for generic client request method
107
- oauth_client.should_receive(:request).exactly(5).times.and_return(response)
108
- basic_client.should_receive(:request).exactly(5).times.and_return(response)
107
+ expect(oauth_client).to receive(:request).exactly(5).times.and_return(response)
108
+ expect(basic_client).to receive(:request).exactly(5).times.and_return(response)
109
109
 
110
110
  # response for merging headers for http methods with no body
111
- oauth_client.should_receive(:merge_default_headers).exactly(3).times.with({})
112
- basic_client.should_receive(:merge_default_headers).exactly(3).times.with({})
111
+ expect(oauth_client).to receive(:merge_default_headers).exactly(3).times.with({})
112
+ expect(basic_client).to receive(:merge_default_headers).exactly(3).times.with({})
113
113
 
114
114
  # response for merging headers for http methods with body
115
- oauth_client.should_receive(:merge_default_headers).exactly(2).times.with(content_type_header)
116
- basic_client.should_receive(:merge_default_headers).exactly(2).times.with(content_type_header)
115
+ expect(oauth_client).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
116
+ expect(basic_client).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
117
117
 
118
118
  [:delete, :get, :head].each do |method|
119
119
  oauth_client.send(method, '/path', {})
@@ -128,15 +128,15 @@ describe JIRA::Client do
128
128
 
129
129
  specify "that call the generic request method" do
130
130
  [:delete, :get, :head].each do |method|
131
- oauth_client.should_receive(:request).with(method, '/path', nil, headers).and_return(response)
132
- basic_client.should_receive(:request).with(method, '/path', nil, headers).and_return(response)
131
+ expect(oauth_client).to receive(:request).with(method, '/path', nil, headers).and_return(response)
132
+ expect(basic_client).to receive(:request).with(method, '/path', nil, headers).and_return(response)
133
133
  oauth_client.send(method, '/path', {})
134
134
  basic_client.send(method, '/path', {})
135
135
  end
136
136
 
137
137
  [:post, :put].each do |method|
138
- oauth_client.should_receive(:request).with(method, '/path', '', merged_headers)
139
- basic_client.should_receive(:request).with(method, '/path', '', merged_headers)
138
+ expect(oauth_client).to receive(:request).with(method, '/path', '', merged_headers)
139
+ expect(basic_client).to receive(:request).with(method, '/path', '', merged_headers)
140
140
  oauth_client.send(method, '/path', '', {})
141
141
  basic_client.send(method, '/path', '', {})
142
142
  end
@@ -145,44 +145,44 @@ describe JIRA::Client do
145
145
  describe "that call a oauth client" do
146
146
  specify "which makes a request" do
147
147
  [:delete, :get, :head].each do |method|
148
- oauth_client.request_client.should_receive(:make_request).with(method, '/path', nil, headers).and_return(response)
148
+ expect(oauth_client.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(response)
149
149
  oauth_client.send(method, '/path', {})
150
150
  end
151
151
  [:post, :put].each do |method|
152
- oauth_client.request_client.should_receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
152
+ expect(oauth_client.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
153
153
  oauth_client.send(method, '/path', '', {})
154
154
  end
155
155
  end
156
156
  end
157
-
157
+
158
158
  describe "that call a http client" do
159
159
  it "which makes a request" do
160
160
  [:delete, :get, :head].each do |method|
161
- basic_client.request_client.should_receive(:make_request).with(method, '/path', nil, headers).and_return(response)
161
+ expect(basic_client.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(response)
162
162
  basic_client.send(method, '/path', headers)
163
163
  end
164
164
  [:post, :put].each do |method|
165
- basic_client.request_client.should_receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
165
+ expect(basic_client.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
166
166
  basic_client.send(method, '/path', '', headers)
167
167
  end
168
168
  end
169
169
  end
170
170
  end
171
-
171
+
172
172
  describe "Resource Factories" do
173
173
  it "gets all projects" do
174
- JIRA::Resource::Project.should_receive(:all).with(oauth_client).and_return([])
175
- JIRA::Resource::Project.should_receive(:all).with(basic_client).and_return([])
176
- oauth_client.Project.all.should == []
177
- basic_client.Project.all.should == []
174
+ expect(JIRA::Resource::Project).to receive(:all).with(oauth_client).and_return([])
175
+ expect(JIRA::Resource::Project).to receive(:all).with(basic_client).and_return([])
176
+ expect(oauth_client.Project.all).to eq([])
177
+ expect(basic_client.Project.all).to eq([])
178
178
  end
179
179
 
180
180
  it "finds a single project" do
181
181
  find_result = double()
182
- JIRA::Resource::Project.should_receive(:find).with(oauth_client, '123').and_return(find_result)
183
- JIRA::Resource::Project.should_receive(:find).with(basic_client, '123').and_return(find_result)
184
- oauth_client.Project.find('123').should == find_result
185
- basic_client.Project.find('123').should == find_result
182
+ expect(JIRA::Resource::Project).to receive(:find).with(oauth_client, '123').and_return(find_result)
183
+ expect(JIRA::Resource::Project).to receive(:find).with(basic_client, '123').and_return(find_result)
184
+ expect(oauth_client.Project.find('123')).to eq(find_result)
185
+ expect(basic_client.Project.find('123')).to eq(find_result)
186
186
  end
187
187
  end
188
188
  end
@@ -10,36 +10,38 @@ describe JIRA::HasManyProxy do
10
10
  let(:collection) { double("collection") }
11
11
 
12
12
  it "has a target class" do
13
- subject.target_class.should == Foo
13
+ expect(subject.target_class).to eq(Foo)
14
14
  end
15
15
 
16
16
  it "has a parent" do
17
- subject.parent.should == parent
17
+ expect(subject.parent).to eq(parent)
18
18
  end
19
19
 
20
20
  it "has a collection" do
21
- subject.collection.should == collection
21
+ expect(subject.collection).to eq(collection)
22
22
  end
23
23
 
24
24
  it "can build a new instance" do
25
25
  client = double('client')
26
26
  foo = double('foo')
27
- parent.stub(:client => client, :to_sym => :parent)
28
- Foo.should_receive(:new).with(client, :attrs => {'foo' => 'bar'}, :parent => parent).and_return(foo)
29
- collection.should_receive(:<<).with(foo)
30
- subject.build('foo' => 'bar').should == foo
27
+ allow(parent).to receive(:client).and_return(client)
28
+ allow(parent).to receive(:to_sym).and_return(:parent)
29
+ expect(Foo).to receive(:new).with(client, :attrs => {'foo' => 'bar'}, :parent => parent).and_return(foo)
30
+ expect(collection).to receive(:<<).with(foo)
31
+ expect(subject.build('foo' => 'bar')).to eq(foo)
31
32
  end
32
33
 
33
34
  it "can get all the instances" do
34
35
  foo = double('foo')
35
36
  client = double('client')
36
- parent.stub(:client => client, :to_sym => :parent)
37
- Foo.should_receive(:all).with(client, :parent => parent).and_return(foo)
38
- subject.all.should == foo
37
+ allow(parent).to receive(:client).and_return(client)
38
+ allow(parent).to receive(:to_sym).and_return(:parent)
39
+ expect(Foo).to receive(:all).with(client, :parent => parent).and_return(foo)
40
+ expect(subject.all).to eq(foo)
39
41
  end
40
42
 
41
43
  it "delegates missing methods to the collection" do
42
- collection.should_receive(:missing_method)
44
+ expect(collection).to receive(:missing_method)
43
45
  subject.missing_method
44
46
  end
45
47
  end
@@ -14,18 +14,18 @@ describe JIRA::HttpClient do
14
14
 
15
15
  let(:response) do
16
16
  response = double("response")
17
- response.stub(:kind_of?).with(Net::HTTPSuccess).and_return(true)
17
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
18
18
  response
19
19
  end
20
20
 
21
21
  let(:cookie_response) do
22
22
  response = double("response")
23
- response.stub(:kind_of?).with(Net::HTTPSuccess).and_return(true)
23
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
24
24
  response
25
25
  end
26
26
 
27
27
  it "creates an instance of Net:HTTP for a basic auth client" do
28
- basic_client.basic_auth_http_conn.class.should == Net::HTTP
28
+ expect(basic_client.basic_auth_http_conn.class).to eq(Net::HTTP)
29
29
  end
30
30
 
31
31
  it "responds to the http methods" do
@@ -33,17 +33,17 @@ describe JIRA::HttpClient do
33
33
  headers = double()
34
34
  basic_auth_http_conn = double()
35
35
  request = double()
36
- basic_client.stub(:basic_auth_http_conn => basic_auth_http_conn)
37
- request.should_receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).exactly(5).times.and_return(request)
38
- basic_auth_http_conn.should_receive(:request).exactly(5).times.with(request).and_return(response)
36
+ allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
37
+ expect(request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).exactly(5).times.and_return(request)
38
+ expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(response)
39
39
  [:delete, :get, :head].each do |method|
40
- Net::HTTP.const_get(method.to_s.capitalize).should_receive(:new).with('/path', headers).and_return(request)
41
- basic_client.make_request(method, '/path', nil, headers).should == response
40
+ expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
41
+ expect(basic_client.make_request(method, '/path', nil, headers)).to eq(response)
42
42
  end
43
43
  [:post, :put].each do |method|
44
- Net::HTTP.const_get(method.to_s.capitalize).should_receive(:new).with('/path', headers).and_return(request)
45
- request.should_receive(:body=).with(body).and_return(request)
46
- basic_client.make_request(method, '/path', body, headers).should == response
44
+ expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
45
+ expect(request).to receive(:body=).with(body).and_return(request)
46
+ expect(basic_client.make_request(method, '/path', body, headers)).to eq(response)
47
47
  end
48
48
  end
49
49
 
@@ -52,18 +52,18 @@ describe JIRA::HttpClient do
52
52
  headers = double()
53
53
  basic_auth_http_conn = double()
54
54
  request = double()
55
- basic_cookie_client.stub(:basic_auth_http_conn => basic_auth_http_conn)
56
- request.should_receive(:basic_auth).with(basic_cookie_client.options[:username], basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
57
- cookie_response.should_receive(:get_fields).with('set-cookie').exactly(5).times
58
- basic_auth_http_conn.should_receive(:request).exactly(5).times.with(request).and_return(cookie_response)
55
+ allow(basic_cookie_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
56
+ expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username], basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
57
+ expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
58
+ expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
59
59
  [:delete, :get, :head].each do |method|
60
- Net::HTTP.const_get(method.to_s.capitalize).should_receive(:new).with('/path', headers).and_return(request)
61
- basic_cookie_client.make_request(method, '/path', nil, headers).should == cookie_response
60
+ expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
61
+ expect(basic_cookie_client.make_request(method, '/path', nil, headers)).to eq(cookie_response)
62
62
  end
63
63
  [:post, :put].each do |method|
64
- Net::HTTP.const_get(method.to_s.capitalize).should_receive(:new).with('/path', headers).and_return(request)
65
- request.should_receive(:body=).with(body).and_return(request)
66
- basic_cookie_client.make_request(method, '/path', body, headers).should == cookie_response
64
+ expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
65
+ expect(request).to receive(:body=).with(body).and_return(request)
66
+ expect(basic_cookie_client.make_request(method, '/path', body, headers)).to eq(cookie_response)
67
67
  end
68
68
  end
69
69
 
@@ -73,17 +73,17 @@ describe JIRA::HttpClient do
73
73
  headers = double()
74
74
  basic_auth_http_conn = double()
75
75
  http_request = double()
76
- Net::HTTP::Get.should_receive(:new).with('/foo', headers).and_return(http_request)
76
+ expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
77
77
 
78
- basic_auth_http_conn.should_receive(:request).with(http_request).and_return(response)
79
- http_request.should_receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).and_return(http_request)
80
- basic_client.stub(:basic_auth_http_conn => basic_auth_http_conn)
78
+ expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
79
+ expect(http_request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).and_return(http_request)
80
+ allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
81
81
  basic_client.make_request(:get, '/foo', body, headers)
82
82
  end
83
83
 
84
84
  it "returns a URI" do
85
85
  uri = URI.parse(basic_client.options[:site])
86
- basic_client.uri.should == uri
86
+ expect(basic_client.uri).to eq(uri)
87
87
  end
88
88
 
89
89
  it "sets up a http connection with options" do
@@ -91,19 +91,19 @@ describe JIRA::HttpClient do
91
91
  uri = double()
92
92
  host = double()
93
93
  port = double()
94
- uri.should_receive(:host).and_return(host)
95
- uri.should_receive(:port).and_return(port)
96
- Net::HTTP.should_receive(:new).with(host, port).and_return(http_conn)
97
- http_conn.should_receive(:use_ssl=).with(basic_client.options[:use_ssl]).and_return(http_conn)
98
- http_conn.should_receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode]).and_return(http_conn)
99
- basic_client.http_conn(uri).should == http_conn
94
+ expect(uri).to receive(:host).and_return(host)
95
+ expect(uri).to receive(:port).and_return(port)
96
+ expect(Net::HTTP).to receive(:new).with(host, port).and_return(http_conn)
97
+ expect(http_conn).to receive(:use_ssl=).with(basic_client.options[:use_ssl]).and_return(http_conn)
98
+ expect(http_conn).to receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode]).and_return(http_conn)
99
+ expect(basic_client.http_conn(uri)).to eq(http_conn)
100
100
  end
101
101
 
102
102
  it "returns a http connection" do
103
103
  http_conn = double()
104
104
  uri = double()
105
- basic_client.should_receive(:uri).and_return(uri)
106
- basic_client.should_receive(:http_conn).and_return(http_conn)
107
- basic_client.basic_auth_http_conn.should == http_conn
105
+ expect(basic_client).to receive(:uri).and_return(uri)
106
+ expect(basic_client).to receive(:http_conn).and_return(http_conn)
107
+ expect(basic_client.basic_auth_http_conn).to eq(http_conn)
108
108
  end
109
109
  end
@@ -2,24 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe JIRA::HTTPError do
4
4
 
5
- let(:response) {
6
- response = double("response")
7
- response.stub(:code => 401)
8
- response.stub(:message => "A MESSAGE WOO")
5
+ let(:response) {
6
+ response = double("response")
7
+ allow(response).to receive(:code).and_return(401)
8
+ allow(response).to receive(:message).and_return("A MESSAGE WOO")
9
9
  response
10
10
  }
11
+
11
12
  subject { described_class.new(response) }
12
13
 
13
14
  it "takes the response object as an argument" do
14
- subject.response.should == response
15
+ expect(subject.response).to eq(response)
15
16
  end
16
17
 
17
18
  it "has a code method" do
18
- subject.code.should == response.code
19
+ expect(subject.code).to eq(response.code)
19
20
  end
20
21
 
21
22
  it "returns code and class from message" do
22
- subject.message.should == response.message
23
+ expect(subject.message).to eq(response.message)
23
24
  end
24
25
 
25
26
  end
@@ -10,76 +10,76 @@ describe JIRA::OauthClient do
10
10
 
11
11
  let(:response) do
12
12
  response = double("response")
13
- response.stub(:kind_of?).with(Net::HTTPSuccess).and_return(true)
13
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
14
14
  response
15
15
  end
16
-
16
+
17
17
  describe "authenticating with oauth" do
18
18
  it "prepends the context path to all authorization and rest paths" do
19
19
  options = [:request_token_path, :authorize_path, :access_token_path]
20
20
  defaults = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::OauthClient::DEFAULT_OPTIONS)
21
21
  options.each do |key|
22
- oauth_client.options[key].should == defaults[:context_path] + defaults[key]
22
+ expect(oauth_client.options[key]).to eq(defaults[:context_path] + defaults[key])
23
23
  end
24
24
  end
25
25
 
26
26
  it "creates a Oauth::Consumer on initialize" do
27
- oauth_client.consumer.class.should == OAuth::Consumer
28
- oauth_client.consumer.key.should == oauth_client.key
29
- oauth_client.consumer.secret.should == oauth_client.secret
27
+ expect(oauth_client.consumer.class).to eq(OAuth::Consumer)
28
+ expect(oauth_client.consumer.key).to eq(oauth_client.key)
29
+ expect(oauth_client.consumer.secret).to eq(oauth_client.secret)
30
30
  end
31
31
 
32
32
  it "returns an OAuth request_token" do
33
33
  # Cannot just check for method delegation as http connection will be attempted
34
34
  request_token = OAuth::RequestToken.new(oauth_client.consumer)
35
- oauth_client.consumer.stub(:get_request_token => request_token)
36
- oauth_client.get_request_token.should == request_token
35
+ allow(oauth_client).to receive(:get_request_token).and_return(request_token)
36
+ expect(oauth_client.get_request_token).to eq(request_token)
37
37
  end
38
38
 
39
39
  it "allows setting the request token" do
40
40
  token = double()
41
- OAuth::RequestToken.should_receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
41
+ expect(OAuth::RequestToken).to receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
42
42
 
43
43
  request_token = oauth_client.set_request_token('foo', 'bar')
44
44
 
45
- request_token.should == token
46
- oauth_client.request_token.should == token
45
+ expect(request_token).to eq(token)
46
+ expect(oauth_client.request_token).to eq(token)
47
47
  end
48
48
 
49
49
  it "allows setting the consumer key" do
50
- oauth_client.key.should == 'foo'
50
+ expect(oauth_client.key).to eq('foo')
51
51
  end
52
52
 
53
53
  it "allows setting the consumer secret" do
54
- oauth_client.secret.should == 'bar'
54
+ expect(oauth_client.secret).to eq('bar')
55
55
  end
56
56
 
57
57
  describe "the access token" do
58
58
 
59
59
  it "initializes" do
60
60
  request_token = OAuth::RequestToken.new(oauth_client.consumer)
61
- oauth_client.consumer.stub(:get_request_token => request_token)
61
+ allow(oauth_client).to receive(:get_request_token).and_return(request_token)
62
62
  mock_access_token = double()
63
- request_token.should_receive(:get_access_token).with(:oauth_verifier => 'abc123').and_return(mock_access_token)
63
+ expect(request_token).to receive(:get_access_token).with(:oauth_verifier => 'abc123').and_return(mock_access_token)
64
64
  oauth_client.init_access_token(:oauth_verifier => 'abc123')
65
- oauth_client.access_token.should == mock_access_token
65
+ expect(oauth_client.access_token).to eq(mock_access_token)
66
66
  end
67
67
 
68
68
  it "raises an exception when accessing without initialisation" do
69
69
  expect {
70
70
  oauth_client.access_token
71
- }.to raise_exception(JIRA::OauthClient::UninitializedAccessTokenError,
71
+ }.to raise_exception(JIRA::OauthClient::UninitializedAccessTokenError,
72
72
  "init_access_token must be called before using the client")
73
73
  end
74
74
 
75
75
  it "allows setting the access token" do
76
76
  token = double()
77
- OAuth::AccessToken.should_receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
77
+ expect(OAuth::AccessToken).to receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
78
78
 
79
79
  access_token = oauth_client.set_access_token('foo', 'bar')
80
80
 
81
- access_token.should == token
82
- oauth_client.access_token.should == token
81
+ expect(access_token).to eq(token)
82
+ expect(oauth_client.access_token).to eq(token)
83
83
  end
84
84
  end
85
85
 
@@ -87,13 +87,13 @@ describe JIRA::OauthClient do
87
87
  it "responds to the http methods" do
88
88
  headers = double()
89
89
  mock_access_token = double()
90
- oauth_client.stub(:access_token => mock_access_token)
90
+ allow(oauth_client).to receive(:access_token).and_return(mock_access_token)
91
91
  [:delete, :get, :head].each do |method|
92
- mock_access_token.should_receive(method).with('/path', headers).and_return(response)
92
+ expect(mock_access_token).to receive(method).with('/path', headers).and_return(response)
93
93
  oauth_client.make_request(method, '/path', '', headers)
94
94
  end
95
95
  [:post, :put].each do |method|
96
- mock_access_token.should_receive(method).with('/path', '', headers).and_return(response)
96
+ expect(mock_access_token).to receive(method).with('/path', '', headers).and_return(response)
97
97
  oauth_client.make_request(method, '/path', '', headers)
98
98
  end
99
99
  end
@@ -102,8 +102,8 @@ describe JIRA::OauthClient do
102
102
  body = nil
103
103
  headers = double()
104
104
  access_token = double()
105
- access_token.should_receive(:send).with(:get, '/foo', headers).and_return(response)
106
- oauth_client.stub(:access_token => access_token)
105
+ expect(access_token).to receive(:send).with(:get, '/foo', headers).and_return(response)
106
+ allow(oauth_client).to receive(:access_token).and_return(access_token)
107
107
  oauth_client.request(:get, '/foo', body, headers)
108
108
  end
109
109
  end