jira-ruby 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +7 -1
  3. data/Guardfile +1 -1
  4. data/Rakefile +4 -5
  5. data/http-basic-example.rb +13 -12
  6. data/jira-ruby.gemspec +9 -10
  7. data/lib/jira-ruby.rb +5 -2
  8. data/lib/jira/base.rb +49 -48
  9. data/lib/jira/base_factory.rb +1 -4
  10. data/lib/jira/client.rb +29 -20
  11. data/lib/jira/has_many_proxy.rb +0 -1
  12. data/lib/jira/http_client.rb +9 -10
  13. data/lib/jira/http_error.rb +3 -5
  14. data/lib/jira/oauth_client.rb +19 -20
  15. data/lib/jira/request_client.rb +3 -4
  16. data/lib/jira/resource/agile.rb +10 -8
  17. data/lib/jira/resource/applinks.rb +5 -8
  18. data/lib/jira/resource/attachment.rb +1 -2
  19. data/lib/jira/resource/board.rb +84 -0
  20. data/lib/jira/resource/comment.rb +0 -2
  21. data/lib/jira/resource/component.rb +1 -3
  22. data/lib/jira/resource/createmeta.rb +12 -14
  23. data/lib/jira/resource/field.rb +22 -22
  24. data/lib/jira/resource/filter.rb +2 -2
  25. data/lib/jira/resource/issue.rb +41 -39
  26. data/lib/jira/resource/issuelink.rb +3 -5
  27. data/lib/jira/resource/issuelinktype.rb +0 -1
  28. data/lib/jira/resource/issuetype.rb +1 -3
  29. data/lib/jira/resource/priority.rb +1 -3
  30. data/lib/jira/resource/project.rb +5 -7
  31. data/lib/jira/resource/rapidview.rb +28 -7
  32. data/lib/jira/resource/remotelink.rb +1 -4
  33. data/lib/jira/resource/resolution.rb +2 -4
  34. data/lib/jira/resource/serverinfo.rb +1 -2
  35. data/lib/jira/resource/sprint.rb +82 -18
  36. data/lib/jira/resource/sprint_report.rb +8 -0
  37. data/lib/jira/resource/status.rb +1 -3
  38. data/lib/jira/resource/transition.rb +2 -6
  39. data/lib/jira/resource/user.rb +12 -2
  40. data/lib/jira/resource/version.rb +1 -3
  41. data/lib/jira/resource/watcher.rb +1 -5
  42. data/lib/jira/resource/webhook.rb +3 -6
  43. data/lib/jira/resource/worklog.rb +3 -5
  44. data/lib/jira/version.rb +1 -1
  45. data/lib/tasks/generate.rake +4 -4
  46. data/spec/integration/attachment_spec.rb +15 -16
  47. data/spec/integration/comment_spec.rb +31 -34
  48. data/spec/integration/component_spec.rb +21 -24
  49. data/spec/integration/field_spec.rb +15 -18
  50. data/spec/integration/issue_spec.rb +44 -48
  51. data/spec/integration/issuelinktype_spec.rb +8 -11
  52. data/spec/integration/issuetype_spec.rb +5 -7
  53. data/spec/integration/priority_spec.rb +5 -8
  54. data/spec/integration/project_spec.rb +13 -20
  55. data/spec/integration/rapidview_spec.rb +17 -10
  56. data/spec/integration/resolution_spec.rb +7 -10
  57. data/spec/integration/status_spec.rb +5 -8
  58. data/spec/integration/transition_spec.rb +17 -20
  59. data/spec/integration/user_spec.rb +24 -8
  60. data/spec/integration/version_spec.rb +21 -25
  61. data/spec/integration/watcher_spec.rb +28 -34
  62. data/spec/integration/webhook.rb +8 -17
  63. data/spec/integration/worklog_spec.rb +30 -34
  64. data/spec/jira/base_factory_spec.rb +11 -12
  65. data/spec/jira/base_spec.rb +204 -228
  66. data/spec/jira/client_spec.rb +26 -28
  67. data/spec/jira/has_many_proxy_spec.rb +11 -12
  68. data/spec/jira/http_client_spec.rb +51 -52
  69. data/spec/jira/http_error_spec.rb +7 -9
  70. data/spec/jira/oauth_client_spec.rb +44 -46
  71. data/spec/jira/request_client_spec.rb +5 -5
  72. data/spec/jira/resource/agile_spec.rb +5 -7
  73. data/spec/jira/resource/attachment_spec.rb +25 -26
  74. data/spec/jira/resource/board_spec.rb +175 -0
  75. data/spec/jira/resource/createmeta_spec.rb +29 -32
  76. data/spec/jira/resource/field_spec.rb +42 -48
  77. data/spec/jira/resource/filter_spec.rb +40 -40
  78. data/spec/jira/resource/issue_spec.rb +87 -89
  79. data/spec/jira/resource/issuelink_spec.rb +1 -1
  80. data/spec/jira/resource/project_factory_spec.rb +2 -4
  81. data/spec/jira/resource/project_spec.rb +33 -33
  82. data/spec/jira/resource/sprint_spec.rb +78 -0
  83. data/spec/jira/resource/user_factory_spec.rb +6 -8
  84. data/spec/jira/resource/worklog_spec.rb +9 -11
  85. data/spec/spec_helper.rb +8 -9
  86. data/spec/support/clients_helper.rb +4 -4
  87. data/spec/support/shared_examples/integration.rb +60 -77
  88. metadata +59 -53
@@ -16,7 +16,7 @@ RSpec.shared_examples 'Client Common Tests' do
16
16
  end
17
17
 
18
18
  it 'merges headers' do
19
- expect(subject.send(:merge_default_headers, {})).to eq({'Accept' => 'application/json'})
19
+ expect(subject.send(:merge_default_headers, {})).to eq('Accept' => 'application/json')
20
20
  end
21
21
 
22
22
  describe 'http methods' do
@@ -30,17 +30,17 @@ RSpec.shared_examples 'Client Common Tests' do
30
30
  # response for merging headers for http methods with body
31
31
  expect(subject).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
32
32
 
33
- [:delete, :get, :head].each { |method| subject.send(method, '/path', {}) }
34
- [:post, :put].each {|method| subject.send(method, '/path', '', content_type_header)}
33
+ %i[delete get head].each { |method| subject.send(method, '/path', {}) }
34
+ %i[post put].each { |method| subject.send(method, '/path', '', content_type_header) }
35
35
  end
36
36
 
37
37
  it 'calls the generic request method' do
38
- [:delete, :get, :head].each do |method|
38
+ %i[delete get head].each do |method|
39
39
  expect(subject).to receive(:request).with(method, '/path', nil, headers).and_return(successful_response)
40
40
  subject.send(method, '/path', {})
41
41
  end
42
42
 
43
- [:post, :put].each do |method|
43
+ %i[post put].each do |method|
44
44
  expect(subject).to receive(:request).with(method, '/path', '', merged_headers)
45
45
  subject.send(method, '/path', '', {})
46
46
  end
@@ -63,11 +63,11 @@ end
63
63
 
64
64
  RSpec.shared_examples 'HttpClient tests' do
65
65
  it 'makes a valid request' do
66
- [:delete, :get, :head].each do |method|
66
+ %i[delete get head].each do |method|
67
67
  expect(subject.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(successful_response)
68
68
  subject.send(method, '/path', headers)
69
69
  end
70
- [:post, :put].each do |method|
70
+ %i[post put].each do |method|
71
71
  expect(subject.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(successful_response)
72
72
  subject.send(method, '/path', '', headers)
73
73
  end
@@ -92,11 +92,11 @@ RSpec.shared_examples 'OAuth Common Tests' do
92
92
 
93
93
  describe 'that call a oauth client' do
94
94
  specify 'which makes a request' do
95
- [:delete, :get, :head].each do |method|
95
+ %i[delete get head].each do |method|
96
96
  expect(subject.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(successful_response)
97
97
  subject.send(method, '/path', {})
98
98
  end
99
- [:post, :put].each do |method|
99
+ %i[post put].each do |method|
100
100
  expect(subject.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(successful_response)
101
101
  subject.send(method, '/path', '', {})
102
102
  end
@@ -108,16 +108,16 @@ describe JIRA::Client do
108
108
  let(:request) { subject.request_client.class }
109
109
  let(:successful_response) do
110
110
  response = double('response')
111
- allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
111
+ allow(response).to receive(:is_a?).with(Net::HTTPSuccess).and_return(true)
112
112
  response
113
113
  end
114
- let(:content_type_header) { {'Content-Type' => 'application/json'} }
115
- let(:headers) { {'Accept' => 'application/json'} }
114
+ let(:content_type_header) { { 'Content-Type' => 'application/json' } }
115
+ let(:headers) { { 'Accept' => 'application/json' } }
116
116
  let(:merged_headers) { headers.merge(content_type_header) }
117
117
 
118
118
  context 'behaviour that applies to all client classes irrespective of authentication method' do
119
119
  it 'allows the overriding of some options' do
120
- client = JIRA::Client.new({:consumer_key => 'foo', :consumer_secret => 'bar', :site => 'http://foo.com/'})
120
+ client = JIRA::Client.new(consumer_key: 'foo', consumer_secret: 'bar', site: 'http://foo.com/')
121
121
  expect(client.options[:site]).to eq('http://foo.com/')
122
122
  expect(JIRA::Client::DEFAULT_OPTIONS[:site]).not_to eq('http://foo.com/')
123
123
  end
@@ -128,10 +128,10 @@ describe JIRA::Client do
128
128
 
129
129
  before(:each) do
130
130
  stub_request(:get, 'https://foo:bar@localhost:2990/jira/rest/api/2/project')
131
- .to_return(status: 200, body: '[]', headers: {} )
131
+ .to_return(status: 200, body: '[]', headers: {})
132
132
 
133
- stub_request(:get, 'https://foo:badpassword@localhost:2990/jira/rest/api/2/project').
134
- to_return(status: 401, headers: {} )
133
+ stub_request(:get, 'https://foo:badpassword@localhost:2990/jira/rest/api/2/project')
134
+ .to_return(status: 401, headers: {})
135
135
  end
136
136
 
137
137
  include_examples 'Client Common Tests'
@@ -147,7 +147,7 @@ describe JIRA::Client do
147
147
  it 'fails with wrong user name and password' do
148
148
  bad_login = JIRA::Client.new(username: 'foo', password: 'badpassword', auth_type: :basic)
149
149
  expect(bad_login.authenticated?).to be_falsey
150
- expect{bad_login.Project.all}.to raise_error JIRA::HTTPError
150
+ expect { bad_login.Project.all }.to raise_error JIRA::HTTPError
151
151
  end
152
152
 
153
153
  it 'only returns a true for #authenticated? once we have requested some data' do
@@ -155,7 +155,6 @@ describe JIRA::Client do
155
155
  expect(subject.Project.all).to be_empty
156
156
  expect(subject.authenticated?).to be_truthy
157
157
  end
158
-
159
158
  end
160
159
 
161
160
  context 'with cookie authentication' do
@@ -164,27 +163,27 @@ describe JIRA::Client do
164
163
  let(:session_cookie) { '6E3487971234567896704A9EB4AE501F' }
165
164
  let(:session_body) do
166
165
  {
167
- 'session': {'name' => "JSESSIONID", 'value' => session_cookie },
168
- 'loginInfo': {'failedLoginCount' => 1, 'loginCount' => 2,
169
- 'lastFailedLoginTime' => (DateTime.now - 2).iso8601,
170
- 'previousLoginTime' => (DateTime.now - 5).iso8601 }
166
+ 'session': { 'name' => 'JSESSIONID', 'value' => session_cookie },
167
+ 'loginInfo': { 'failedLoginCount' => 1, 'loginCount' => 2,
168
+ 'lastFailedLoginTime' => (DateTime.now - 2).iso8601,
169
+ 'previousLoginTime' => (DateTime.now - 5).iso8601 }
171
170
  }
172
171
  end
173
172
 
174
173
  before(:each) do
175
174
  # General case of API call with no authentication, or wrong authentication
176
- stub_request(:post, 'https://localhost:2990/jira/rest/auth/1/session').
177
- to_return(status: 401, headers: {} )
175
+ stub_request(:post, 'https://localhost:2990/jira/rest/auth/1/session')
176
+ .to_return(status: 401, headers: {})
178
177
 
179
178
  # Now special case of API with correct authentication. This gets checked first by RSpec.
180
179
  stub_request(:post, 'https://localhost:2990/jira/rest/auth/1/session')
181
180
  .with(body: '{"username":"foo","password":"bar"}')
182
181
  .to_return(status: 200, body: session_body.to_json,
183
- headers: { 'Set-Cookie': "JSESSIONID=#{session_cookie}; Path=/; HttpOnly"})
182
+ headers: { 'Set-Cookie': "JSESSIONID=#{session_cookie}; Path=/; HttpOnly" })
184
183
 
185
184
  stub_request(:get, 'https://localhost:2990/jira/rest/api/2/project')
186
- .with(headers: { cookie: "JSESSIONID=#{session_cookie}" } )
187
- .to_return(status: 200, body: '[]', headers: {} )
185
+ .with(headers: { cookie: "JSESSIONID=#{session_cookie}" })
186
+ .to_return(status: 200, body: '[]', headers: {})
188
187
  end
189
188
 
190
189
  include_examples 'Client Common Tests'
@@ -220,4 +219,3 @@ describe JIRA::Client do
220
219
  include_examples 'OAuth Common Tests'
221
220
  end
222
221
  end
223
-
@@ -1,46 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::HasManyProxy do
4
-
5
- class Foo ; end
4
+ class Foo; end
6
5
 
7
6
  subject { JIRA::HasManyProxy.new(parent, Foo, collection) }
8
7
 
9
- let(:parent) { double("parent") }
10
- let(:collection) { double("collection") }
8
+ let(:parent) { double('parent') }
9
+ let(:collection) { double('collection') }
11
10
 
12
- it "has a target class" do
11
+ it 'has a target class' do
13
12
  expect(subject.target_class).to eq(Foo)
14
13
  end
15
14
 
16
- it "has a parent" do
15
+ it 'has a parent' do
17
16
  expect(subject.parent).to eq(parent)
18
17
  end
19
18
 
20
- it "has a collection" do
19
+ it 'has a collection' do
21
20
  expect(subject.collection).to eq(collection)
22
21
  end
23
22
 
24
- it "can build a new instance" do
23
+ it 'can build a new instance' do
25
24
  client = double('client')
26
25
  foo = double('foo')
27
26
  allow(parent).to receive(:client).and_return(client)
28
27
  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)
28
+ expect(Foo).to receive(:new).with(client, attrs: { 'foo' => 'bar' }, parent: parent).and_return(foo)
30
29
  expect(collection).to receive(:<<).with(foo)
31
30
  expect(subject.build('foo' => 'bar')).to eq(foo)
32
31
  end
33
32
 
34
- it "can get all the instances" do
33
+ it 'can get all the instances' do
35
34
  foo = double('foo')
36
35
  client = double('client')
37
36
  allow(parent).to receive(:client).and_return(client)
38
37
  allow(parent).to receive(:to_sym).and_return(:parent)
39
- expect(Foo).to receive(:all).with(client, :parent => parent).and_return(foo)
38
+ expect(Foo).to receive(:all).with(client, parent: parent).and_return(foo)
40
39
  expect(subject.all).to eq(foo)
41
40
  end
42
41
 
43
- it "delegates missing methods to the collection" do
42
+ it 'delegates missing methods to the collection' do
44
43
  expect(collection).to receive(:missing_method)
45
44
  subject.missing_method
46
45
  end
@@ -1,63 +1,62 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::HttpClient do
4
-
5
4
  let(:basic_client) do
6
5
  options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS)
7
6
  JIRA::HttpClient.new(options)
8
7
  end
9
8
 
10
9
  let(:basic_cookie_client) do
11
- options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(:use_cookies => true)
10
+ options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(use_cookies: true)
12
11
  JIRA::HttpClient.new(options)
13
12
  end
14
13
 
15
14
  let(:basic_cookie_client_with_context_path) do
16
15
  options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
17
- :use_cookies => true,
18
- :context_path => '/context'
16
+ use_cookies: true,
17
+ context_path: '/context'
19
18
  )
20
19
  JIRA::HttpClient.new(options)
21
20
  end
22
21
 
23
22
  let(:basic_cookie_client_with_additional_cookies) do
24
23
  options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
25
- :use_cookies => true,
26
- :additional_cookies => ['sessionToken=abc123', 'internal=true']
24
+ use_cookies: true,
25
+ additional_cookies: ['sessionToken=abc123', 'internal=true']
27
26
  )
28
27
  JIRA::HttpClient.new(options)
29
28
  end
30
29
 
31
30
  let(:basic_client_cert_client) do
32
31
  options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
33
- :use_client_cert => true,
34
- :cert => 'public certificate contents',
35
- :key => 'private key contents'
32
+ use_client_cert: true,
33
+ cert: 'public certificate contents',
34
+ key: 'private key contents'
36
35
  )
37
36
  JIRA::HttpClient.new(options)
38
37
  end
39
38
 
40
39
  let(:response) do
41
- response = double("response")
40
+ response = double('response')
42
41
  allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
43
42
  response
44
43
  end
45
44
 
46
45
  let(:cookie_response) do
47
- response = double("response")
46
+ response = double('response')
48
47
  allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(true)
49
48
  response
50
49
  end
51
50
 
52
- it "creates an instance of Net:HTTP for a basic auth client" do
51
+ it 'creates an instance of Net:HTTP for a basic auth client' do
53
52
  expect(basic_client.basic_auth_http_conn.class).to eq(Net::HTTP)
54
53
  end
55
54
 
56
- it "makes a correct HTTP request for make_cookie_auth_request" do
57
- request = double()
58
- basic_auth_http_conn = double()
55
+ it 'makes a correct HTTP request for make_cookie_auth_request' do
56
+ request = double
57
+ basic_auth_http_conn = double
59
58
 
60
- headers = {"Content-Type" => "application/json"}
59
+ headers = { 'Content-Type' => 'application/json' }
61
60
  expected_path = '/context/rest/auth/1/session'
62
61
  expected_body = '{"username":"","password":""}'
63
62
 
@@ -73,72 +72,72 @@ describe JIRA::HttpClient do
73
72
  basic_cookie_client_with_context_path.make_cookie_auth_request
74
73
  end
75
74
 
76
- it "responds to the http methods" do
75
+ it 'responds to the http methods' do
77
76
  body = ''
78
- headers = double()
79
- basic_auth_http_conn = double()
80
- request = double()
77
+ headers = double
78
+ basic_auth_http_conn = double
79
+ request = double
81
80
  allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
82
81
  expect(request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).exactly(5).times.and_return(request)
83
82
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(response)
84
- [:delete, :get, :head].each do |method|
83
+ %i[delete get head].each do |method|
85
84
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
86
85
  expect(basic_client.make_request(method, '/path', nil, headers)).to eq(response)
87
86
  end
88
- [:post, :put].each do |method|
87
+ %i[post put].each do |method|
89
88
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
90
89
  expect(request).to receive(:body=).with(body).and_return(request)
91
90
  expect(basic_client.make_request(method, '/path', body, headers)).to eq(response)
92
91
  end
93
92
  end
94
93
 
95
- it "gets and sets cookies" do
94
+ it 'gets and sets cookies' do
96
95
  body = ''
97
- headers = double()
98
- basic_auth_http_conn = double()
99
- request = double()
96
+ headers = double
97
+ basic_auth_http_conn = double
98
+ request = double
100
99
  allow(basic_cookie_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
101
100
  expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username], basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
102
101
  expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
103
102
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
104
- [:delete, :get, :head].each do |method|
103
+ %i[delete get head].each do |method|
105
104
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
106
105
  expect(basic_cookie_client.make_request(method, '/path', nil, headers)).to eq(cookie_response)
107
106
  end
108
- [:post, :put].each do |method|
107
+ %i[post put].each do |method|
109
108
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
110
109
  expect(request).to receive(:body=).with(body).and_return(request)
111
110
  expect(basic_cookie_client.make_request(method, '/path', body, headers)).to eq(cookie_response)
112
111
  end
113
112
  end
114
113
 
115
- it "sets additional cookies when they are provided" do
114
+ it 'sets additional cookies when they are provided' do
116
115
  client = basic_cookie_client_with_additional_cookies
117
116
  body = ''
118
- headers = double()
119
- basic_auth_http_conn = double()
120
- request = double()
117
+ headers = double
118
+ basic_auth_http_conn = double
119
+ request = double
121
120
  allow(client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
122
121
  expect(request).to receive(:basic_auth).with(client.options[:username], client.options[:password]).exactly(5).times.and_return(request)
123
- expect(request).to receive(:add_field).with("Cookie", "sessionToken=abc123; internal=true").exactly(5).times
122
+ expect(request).to receive(:add_field).with('Cookie', 'sessionToken=abc123; internal=true').exactly(5).times
124
123
  expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
125
124
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
126
- [:delete, :get, :head].each do |method|
125
+ %i[delete get head].each do |method|
127
126
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
128
127
  expect(client.make_request(method, '/path', nil, headers)).to eq(cookie_response)
129
128
  end
130
- [:post, :put].each do |method|
129
+ %i[post put].each do |method|
131
130
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
132
131
  expect(request).to receive(:body=).with(body).and_return(request)
133
132
  expect(client.make_request(method, '/path', body, headers)).to eq(cookie_response)
134
133
  end
135
134
  end
136
135
 
137
- it "performs a basic http client request" do
136
+ it 'performs a basic http client request' do
138
137
  body = nil
139
- headers = double()
140
- basic_auth_http_conn = double()
141
- http_request = double()
138
+ headers = double
139
+ basic_auth_http_conn = double
140
+ http_request = double
142
141
  expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
143
142
 
144
143
  expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
@@ -147,11 +146,11 @@ describe JIRA::HttpClient do
147
146
  basic_client.make_request(:get, '/foo', body, headers)
148
147
  end
149
148
 
150
- it "performs a basic http client request with a full domain" do
149
+ it 'performs a basic http client request with a full domain' do
151
150
  body = nil
152
- headers = double()
153
- basic_auth_http_conn = double()
154
- http_request = double()
151
+ headers = double
152
+ basic_auth_http_conn = double
153
+ http_request = double
155
154
  expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
156
155
 
157
156
  expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
@@ -160,16 +159,16 @@ describe JIRA::HttpClient do
160
159
  basic_client.make_request(:get, 'http://mydomain.com/foo', body, headers)
161
160
  end
162
161
 
163
- it "returns a URI" do
162
+ it 'returns a URI' do
164
163
  uri = URI.parse(basic_client.options[:site])
165
164
  expect(basic_client.uri).to eq(uri)
166
165
  end
167
166
 
168
- it "sets up a http connection with options" do
169
- http_conn = double()
170
- uri = double()
171
- host = double()
172
- port = double()
167
+ it 'sets up a http connection with options' do
168
+ http_conn = double
169
+ uri = double
170
+ host = double
171
+ port = double
173
172
  expect(uri).to receive(:host).and_return(host)
174
173
  expect(uri).to receive(:port).and_return(port)
175
174
  expect(Net::HTTP).to receive(:new).with(host, port).and_return(http_conn)
@@ -195,9 +194,9 @@ describe JIRA::HttpClient do
195
194
  expect(basic_client_cert_client.http_conn(uri)).to eq(http_conn)
196
195
  end
197
196
 
198
- it "returns a http connection" do
199
- http_conn = double()
200
- uri = double()
197
+ it 'returns a http connection' do
198
+ http_conn = double
199
+ uri = double
201
200
  expect(basic_client).to receive(:uri).and_return(uri)
202
201
  expect(basic_client).to receive(:http_conn).and_return(http_conn)
203
202
  expect(basic_client.basic_auth_http_conn).to eq(http_conn)
@@ -1,26 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::HTTPError do
4
-
5
- let(:response) {
6
- response = double("response")
4
+ let(:response) do
5
+ response = double('response')
7
6
  allow(response).to receive(:code).and_return(401)
8
- allow(response).to receive(:message).and_return("A MESSAGE WOO")
7
+ allow(response).to receive(:message).and_return('A MESSAGE WOO')
9
8
  response
10
- }
9
+ end
11
10
 
12
11
  subject { described_class.new(response) }
13
12
 
14
- it "takes the response object as an argument" do
13
+ it 'takes the response object as an argument' do
15
14
  expect(subject.response).to eq(response)
16
15
  end
17
16
 
18
- it "has a code method" do
17
+ it 'has a code method' do
19
18
  expect(subject.code).to eq(response.code)
20
19
  end
21
20
 
22
- it "returns code and class from message" do
21
+ it 'returns code and class from message' do
23
22
  expect(subject.message).to eq(response.message)
24
23
  end
25
-
26
24
  end