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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc4f6eb059f491b8aeaf07b2ee453aa9eee6687b
4
- data.tar.gz: 29f02ed0e3c66b1a06d71342cf7e04574d282c94
3
+ metadata.gz: fd0485d4d1924b9830318cc9875ff1d5284f605a
4
+ data.tar.gz: b211fbe17e3ffa4033a93ab043abeeb93db0d5df
5
5
  SHA512:
6
- metadata.gz: 0f176491a5f2ff1558d883f0ac6e5d5b92b2f9aac29a2b6183720e09bfd3ec8a7ae96a12e257f4c92e9f293ddbfc2828287c019dc38a45fb194ac0bcd01d2937
7
- data.tar.gz: e3b7707569609d99b6431bc20c9f8def378f15286b161e40d51941b9199343ef930a0ad10bee27c80f24dc7b3596f9da5d3ff752c143d1e13f4fdbc02a628406
6
+ metadata.gz: d26f6b648a24d94301771c970c224acce705508354f58eee97884ddd92fcac60a1779c332a248a8b4ad9bd03af6ebb4ae10e4a37416f44f49ddab534416566fa
7
+ data.tar.gz: 16293a18535b195e2df37a86b25195de1e39cd68ab350e3f872753e3537fd8090548058aa6d3ec52dcfdf8ac5c36326fcc6a3036e79edd49545c303d06c66f9b
data/jira-ruby.gemspec CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency "railties"
22
- s.add_runtime_dependency "oauth"
23
- s.add_runtime_dependency "activesupport"
24
- s.add_development_dependency "webmock"
25
- s.add_development_dependency "rspec"
26
- s.add_development_dependency "rake"
21
+ s.add_development_dependency "railties", '~> 4.1.4'
22
+ s.add_runtime_dependency "oauth", '~> 0.4.7'
23
+ s.add_runtime_dependency "activesupport", '~> 4.1.4'
24
+ s.add_development_dependency "webmock", '~> 1.18.0'
25
+ s.add_development_dependency "rspec", '~> 3.0.0'
26
+ s.add_development_dependency "rake", '~> 10.3.2'
27
27
  end
28
28
 
data/lib/jira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -69,7 +69,7 @@ describe JIRA::Resource::Issue do
69
69
  it "fails to save when fields and update are missing" do
70
70
  subject = client.Issue.build('id' => '10002')
71
71
  subject.fetch
72
- subject.save('missing' => 'fields and update').should be_false
72
+ expect(subject.save('missing' => 'fields and update')).to be_falsey
73
73
  end
74
74
 
75
75
  end
@@ -30,10 +30,10 @@ describe JIRA::Resource::Project do
30
30
  to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.issues.json'))
31
31
  subject = client.Project.build('key' => key)
32
32
  issues = subject.issues
33
- issues.length.should == 11
33
+ expect(issues.length).to eq(11)
34
34
  issues.each do |issue|
35
- issue.class.should == JIRA::Resource::Issue
36
- issue.expanded?.should be_false
35
+ expect(issue.class).to eq(JIRA::Resource::Issue)
36
+ expect(issue.expanded?).to be_falsey
37
37
  end
38
38
 
39
39
  end
@@ -46,9 +46,9 @@ describe JIRA::Resource::Project do
46
46
  to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.json'))
47
47
 
48
48
  subject = client.Project.find(key)
49
- subject.components.length.should == 2
49
+ expect(subject.components.length).to eq(2)
50
50
  subject.components.each do |component|
51
- component.class.should == JIRA::Resource::Component
51
+ expect(component.class).to eq(JIRA::Resource::Component)
52
52
  end
53
53
 
54
54
  end
@@ -43,7 +43,7 @@ describe JIRA::Resource::Transition do
43
43
  .with(:body => attributes_for_post.to_json)
44
44
  .to_return(:status => 200, :body => get_mock_from_path(:post))
45
45
  subject = build_receiver.build
46
- subject.save(attributes_for_post).should be_true
46
+ expect(subject.save(attributes_for_post)).to be_truthy
47
47
  end
48
48
  end
49
49
 
@@ -9,38 +9,38 @@ describe JIRA::BaseFactory do
9
9
  subject { JIRA::Resource::FooFactory.new(client) }
10
10
 
11
11
  it "initializes correctly" do
12
- subject.class.should == JIRA::Resource::FooFactory
13
- subject.client.should == client
14
- subject.target_class.should == JIRA::Resource::Foo
12
+ expect(subject.class).to eq(JIRA::Resource::FooFactory)
13
+ expect(subject.client).to eq(client)
14
+ expect(subject.target_class).to eq(JIRA::Resource::Foo)
15
15
  end
16
16
 
17
17
  it "proxies all to the target class" do
18
- JIRA::Resource::Foo.should_receive(:all).with(client)
18
+ expect(JIRA::Resource::Foo).to receive(:all).with(client)
19
19
  subject.all
20
20
  end
21
21
 
22
22
  it "proxies find to the target class" do
23
- JIRA::Resource::Foo.should_receive(:find).with(client, 'FOO')
23
+ expect(JIRA::Resource::Foo).to receive(:find).with(client, 'FOO')
24
24
  subject.find('FOO')
25
25
  end
26
26
 
27
27
  it "returns the target class" do
28
- subject.target_class.should == JIRA::Resource::Foo
28
+ expect(subject.target_class).to eq(JIRA::Resource::Foo)
29
29
  end
30
30
 
31
31
  it "proxies build to the target class" do
32
32
  attrs = double()
33
- JIRA::Resource::Foo.should_receive(:build).with(client, attrs)
33
+ expect(JIRA::Resource::Foo).to receive(:build).with(client, attrs)
34
34
  subject.build(attrs)
35
35
  end
36
36
 
37
37
  it "proxies collection path to the target class" do
38
- JIRA::Resource::Foo.should_receive(:collection_path).with(client)
38
+ expect(JIRA::Resource::Foo).to receive(:collection_path).with(client)
39
39
  subject.collection_path
40
40
  end
41
41
 
42
42
  it "proxies singular path to the target class" do
43
- JIRA::Resource::Foo.should_receive(:singular_path).with(client, 'FOO')
43
+ expect(JIRA::Resource::Foo).to receive(:singular_path).with(client, 'FOO')
44
44
  subject.singular_path('FOO')
45
45
  end
46
46
  end
@@ -37,97 +37,98 @@ describe JIRA::Base do
37
37
  subject { JIRA::Resource::Deadbeef.new(client, :attrs => attrs) }
38
38
 
39
39
  it "assigns the client and attrs" do
40
- subject.client.should == client
41
- subject.attrs.should == attrs
40
+ expect(subject.client).to eq(client)
41
+ expect(subject.attrs).to eq(attrs)
42
42
  end
43
43
 
44
44
  it "returns all the deadbeefs" do
45
45
  response = double()
46
- response.should_receive(:body).and_return('[{"self":"http://deadbeef/","id":"98765"}]')
47
- client.should_receive(:get).with('/jira/rest/api/2/deadbeef').and_return(response)
48
- JIRA::Resource::Deadbeef.should_receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
46
+ expect(response).to receive(:body).and_return('[{"self":"http://deadbeef/","id":"98765"}]')
47
+ expect(client).to receive(:get).with('/jira/rest/api/2/deadbeef').and_return(response)
48
+ expect(JIRA::Resource::Deadbeef).to receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
49
49
  deadbeefs = JIRA::Resource::Deadbeef.all(client)
50
- deadbeefs.length.should == 1
50
+ expect(deadbeefs.length).to eq(1)
51
51
  first = deadbeefs.first
52
- first.class.should == JIRA::Resource::Deadbeef
53
- first.attrs['self'].should == 'http://deadbeef/'
54
- first.attrs['id'].should == '98765'
55
- first.expanded?.should be_false
52
+ expect(first.class).to eq(JIRA::Resource::Deadbeef)
53
+ expect(first.attrs['self']).to eq('http://deadbeef/')
54
+ expect(first.attrs['id']).to eq('98765')
55
+ expect(first.expanded?).to be_falsey
56
56
  end
57
57
 
58
58
  it "finds a deadbeef by id" do
59
- response = double()
60
- response.stub(:body).and_return('{"self":"http://deadbeef/","id":"98765"}')
61
- client.should_receive(:get).with('/jira/rest/api/2/deadbeef/98765').and_return(response)
62
- JIRA::Resource::Deadbeef.should_receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
59
+ response = instance_double("Response", body: '{"self":"http://deadbeef/","id":"98765"}')
60
+ expect(client).to receive(:get).with('/jira/rest/api/2/deadbeef/98765').and_return(response)
61
+ expect(JIRA::Resource::Deadbeef).to receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
63
62
  deadbeef = JIRA::Resource::Deadbeef.find(client, '98765')
64
- deadbeef.client.should == client
65
- deadbeef.attrs['self'].should == 'http://deadbeef/'
66
- deadbeef.attrs['id'].should == '98765'
67
- deadbeef.expanded?.should be_true
63
+ expect(deadbeef.client).to eq(client)
64
+ expect(deadbeef.attrs['self']).to eq('http://deadbeef/')
65
+ expect(deadbeef.attrs['id']).to eq('98765')
66
+ expect(deadbeef.expanded?).to be_truthy
68
67
  end
69
68
 
70
69
  it "finds a deadbeef containing changelog by id" do
71
- response = double()
72
- response.stub(:body).and_return('{"self":"http://deadbeef/","id":"98765","changelog":{"histories":[]}}')
73
- client.should_receive(:get).with('/jira/rest/api/2/deadbeef/98765?expand=changelog').and_return(response)
70
+ response = instance_double(
71
+ "Response",
72
+ body: '{"self":"http://deadbeef/","id":"98765","changelog":{"histories":[]}}'
73
+ )
74
+ expect(client).to receive(:get).with('/jira/rest/api/2/deadbeef/98765?expand=changelog').and_return(response)
74
75
 
75
- JIRA::Resource::Deadbeef.should_receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
76
+ expect(JIRA::Resource::Deadbeef).to receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
76
77
 
77
78
  deadbeef = JIRA::Resource::Deadbeef.find(client, '98765', {expand:'changelog'})
78
- deadbeef.client.should == client
79
- deadbeef.attrs['self'].should == 'http://deadbeef/'
80
- deadbeef.attrs['id'].should == '98765'
81
- deadbeef.expanded?.should be_true
82
- deadbeef.attrs['changelog']['histories'].should == []
79
+ expect(deadbeef.client).to eq(client)
80
+ expect(deadbeef.attrs['self']).to eq('http://deadbeef/')
81
+ expect(deadbeef.attrs['id']).to eq('98765')
82
+ expect(deadbeef.expanded?).to be_truthy
83
+ expect(deadbeef.attrs['changelog']['histories']).to eq([])
83
84
  end
84
85
 
85
86
  it "builds a deadbeef" do
86
87
  deadbeef = JIRA::Resource::Deadbeef.build(client, 'id' => "98765" )
87
- deadbeef.expanded?.should be_false
88
+ expect(deadbeef.expanded?).to be_falsey
88
89
 
89
- deadbeef.client.should == client
90
- deadbeef.attrs['id'].should == '98765'
90
+ expect(deadbeef.client).to eq(client)
91
+ expect(deadbeef.attrs['id']).to eq('98765')
91
92
  end
92
93
 
93
94
  it "returns the endpoint name" do
94
- subject.class.endpoint_name.should == 'deadbeef'
95
+ expect(subject.class.endpoint_name).to eq('deadbeef')
95
96
  end
96
97
 
97
98
  it "returns the path_component" do
98
99
  attrs['id'] = '123'
99
- subject.path_component.should == '/deadbeef/123'
100
+ expect(subject.path_component).to eq('/deadbeef/123')
100
101
  end
101
102
 
102
103
  it "returns the path component for unsaved instances" do
103
- subject.path_component.should == '/deadbeef'
104
+ expect(subject.path_component).to eq('/deadbeef')
104
105
  end
105
106
 
106
107
  it "converts to a symbol" do
107
- subject.to_sym.should == :deadbeef
108
+ expect(subject.to_sym).to eq(:deadbeef)
108
109
  end
109
110
 
110
111
  describe "collection_path" do
111
112
 
112
113
  before(:each) do
113
- client.should_receive(:options).and_return(:rest_base_path => '/deadbeef/bar')
114
+ expect(client).to receive(:options).and_return(:rest_base_path => '/deadbeef/bar')
114
115
  end
115
116
 
116
117
  it "returns the collection_path" do
117
- subject.collection_path.should == '/deadbeef/bar/deadbeef'
118
+ expect(subject.collection_path).to eq('/deadbeef/bar/deadbeef')
118
119
  end
119
120
 
120
121
  it "returns the collection_path with a prefix" do
121
- subject.collection_path('/baz/').should == '/deadbeef/bar/baz/deadbeef'
122
+ expect(subject.collection_path('/baz/')).to eq('/deadbeef/bar/baz/deadbeef')
122
123
  end
123
124
 
124
125
  it "has a class method that returns the collection_path" do
125
- subject.class.collection_path(client).should == '/deadbeef/bar/deadbeef'
126
+ expect(subject.class.collection_path(client)).to eq('/deadbeef/bar/deadbeef')
126
127
  end
127
128
  end
128
129
 
129
130
  it "parses json" do
130
- described_class.parse_json('{"foo":"bar"}').should == {"foo" => "bar"}
131
+ expect(described_class.parse_json('{"foo":"bar"}')).to eq({"foo" => "bar"})
131
132
  end
132
133
 
133
134
  describe "dynamic instance methods" do
@@ -136,17 +137,17 @@ describe JIRA::Base do
136
137
  subject { JIRA::Resource::Deadbeef.new(client, :attrs => attrs) }
137
138
 
138
139
  it "responds to each of the top level attribute names" do
139
- subject.should respond_to(:foo)
140
- subject.should respond_to('flum')
141
- subject.should respond_to(:object_id)
140
+ expect(subject).to respond_to(:foo)
141
+ expect(subject).to respond_to('flum')
142
+ expect(subject).to respond_to(:object_id)
142
143
 
143
- subject.foo.should == 'bar'
144
- subject.flum.should == 'goo'
144
+ expect(subject.foo).to eq('bar')
145
+ expect(subject.flum).to eq('goo')
145
146
 
146
147
  # Should not override existing method names, but should still allow
147
148
  # access to their values via the attrs[] hash
148
- subject.object_id.should_not == 'dummy'
149
- subject.attrs['object_id'].should == 'dummy'
149
+ expect(subject.object_id).not_to eq('dummy')
150
+ expect(subject.attrs['object_id']).to eq('dummy')
150
151
  end
151
152
  end
152
153
 
@@ -157,23 +158,22 @@ describe JIRA::Base do
157
158
  describe "not cached" do
158
159
 
159
160
  before(:each) do
160
- response = double()
161
- response.stub(:body).and_return('{"self":"http://deadbeef/","id":"98765"}')
162
- client.should_receive(:get).with('/jira/rest/api/2/deadbeef/98765').and_return(response)
163
- JIRA::Resource::Deadbeef.should_receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
161
+ response = instance_double("Response", body: '{"self":"http://deadbeef/","id":"98765"}')
162
+ expect(client).to receive(:get).with('/jira/rest/api/2/deadbeef/98765').and_return(response)
163
+ expect(JIRA::Resource::Deadbeef).to receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
164
164
  end
165
165
 
166
166
  it "sets expanded to true after fetch" do
167
- subject.expanded?.should be_false
167
+ expect(subject.expanded?).to be_falsey
168
168
  subject.fetch
169
- subject.expanded?.should be_true
169
+ expect(subject.expanded?).to be_truthy
170
170
  end
171
171
 
172
172
  it "performs a fetch" do
173
- subject.expanded?.should be_false
173
+ expect(subject.expanded?).to be_falsey
174
174
  subject.fetch
175
- subject.self.should == "http://deadbeef/"
176
- subject.id.should == "98765"
175
+ expect(subject.self).to eq("http://deadbeef/")
176
+ expect(subject.id).to eq("98765")
177
177
  end
178
178
 
179
179
  it "performs a fetch if already fetched and force flag is true" do
@@ -186,24 +186,26 @@ describe JIRA::Base do
186
186
  describe "cached" do
187
187
  it "doesn't perform a fetch if already fetched" do
188
188
  subject.expanded = true
189
- client.should_not_receive(:get)
189
+ expect(client).not_to receive(:get)
190
190
  subject.fetch
191
191
  end
192
192
  end
193
193
 
194
194
  context "with expand parameter 'changelog'" do
195
195
  it "fetchs changelogs '" do
196
- response = double()
197
- response.stub(:body).and_return('{"self":"http://deadbeef/","id":"98765","changelog":{"histories":[]}}')
198
- client.should_receive(:get).with('/jira/rest/api/2/deadbeef/98765?expand=changelog').and_return(response)
196
+ response = instance_double(
197
+ "Response",
198
+ body: '{"self":"http://deadbeef/","id":"98765","changelog":{"histories":[]}}'
199
+ )
200
+ expect(client).to receive(:get).with('/jira/rest/api/2/deadbeef/98765?expand=changelog').and_return(response)
199
201
 
200
- JIRA::Resource::Deadbeef.should_receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
202
+ expect(JIRA::Resource::Deadbeef).to receive(:collection_path).and_return('/jira/rest/api/2/deadbeef')
201
203
 
202
204
  subject.fetch(false, {expand:'changelog'})
203
205
 
204
- subject.self.should == "http://deadbeef/"
205
- subject.id.should == "98765"
206
- subject.changelog['histories'].should == []
206
+ expect(subject.self).to eq("http://deadbeef/")
207
+ expect(subject.id).to eq("98765")
208
+ expect(subject.changelog['histories']).to eq([])
207
209
  end
208
210
  end
209
211
  end
@@ -215,39 +217,39 @@ describe JIRA::Base do
215
217
  subject { JIRA::Resource::Deadbeef.new(client) }
216
218
 
217
219
  before(:each) do
218
- subject.should_receive(:url).and_return('/foo/bar')
220
+ expect(subject).to receive(:url).and_return('/foo/bar')
219
221
  end
220
222
 
221
223
  it "POSTs a new record" do
222
- response.stub(:body => '{"id":"123"}')
223
- subject.stub(:new_record? => true)
224
- client.should_receive(:post).with('/foo/bar','{"foo":"bar"}').and_return(response)
225
- subject.save("foo" => "bar").should be_true
226
- subject.id.should == "123"
227
- subject.expanded.should be_false
224
+ response = instance_double("Response", body: '{"id":"123"}')
225
+ allow(subject).to receive(:new_record?) { true }
226
+ expect(client).to receive(:post).with('/foo/bar','{"foo":"bar"}').and_return(response)
227
+ expect(subject.save("foo" => "bar")).to be_truthy
228
+ expect(subject.id).to eq("123")
229
+ expect(subject.expanded).to be_falsey
228
230
  end
229
231
 
230
232
  it "PUTs an existing record" do
231
- response.stub(:body => nil)
232
- subject.stub(:new_record? => false)
233
- client.should_receive(:put).with('/foo/bar','{"foo":"bar"}').and_return(response)
234
- subject.save("foo" => "bar").should be_true
235
- subject.expanded.should be_false
233
+ response = instance_double("Response", body: nil)
234
+ allow(subject).to receive(:new_record?) { false }
235
+ expect(client).to receive(:put).with('/foo/bar','{"foo":"bar"}').and_return(response)
236
+ expect(subject.save("foo" => "bar")).to be_truthy
237
+ expect(subject.expanded).to be_falsey
236
238
  end
237
239
 
238
240
  it "merges attrs on save" do
239
- response.stub(:body => nil)
240
- client.should_receive(:post).with('/foo/bar','{"foo":{"fum":"dum"}}').and_return(response)
241
+ response = instance_double("Response", body: nil)
242
+ expect(client).to receive(:post).with('/foo/bar','{"foo":{"fum":"dum"}}').and_return(response)
241
243
  subject.attrs = {"foo" => {"bar" => "baz"}}
242
244
  subject.save({"foo" => {"fum" => "dum"}})
243
- subject.foo.should == {"bar" => "baz", "fum" => "dum"}
245
+ expect(subject.foo).to eq({"bar" => "baz", "fum" => "dum"})
244
246
  end
245
247
 
246
248
  it "returns false when an invalid field is set" do # The JIRA REST API apparently ignores fields that you aren't allowed to set manually
247
- response.stub(:body => '{"errorMessages":["blah"]}', :status => 400)
248
- subject.stub(:new_record? => false)
249
- client.should_receive(:put).with('/foo/bar','{"invalid_field":"foobar"}').and_raise(JIRA::HTTPError.new(response))
250
- subject.save("invalid_field" => "foobar").should be_false
249
+ response = instance_double("Response", body: '{"errorMessages":["blah"]}', status: 400)
250
+ allow(subject).to receive(:new_record?) { false }
251
+ expect(client).to receive(:put).with('/foo/bar','{"invalid_field":"foobar"}').and_raise(JIRA::HTTPError.new(response))
252
+ expect(subject.save("invalid_field" => "foobar")).to be_falsey
251
253
  end
252
254
 
253
255
  end
@@ -258,33 +260,31 @@ describe JIRA::Base do
258
260
  subject { JIRA::Resource::Deadbeef.new(client) }
259
261
 
260
262
  before(:each) do
261
- subject.should_receive(:url).and_return('/foo/bar')
263
+ expect(subject).to receive(:url).and_return('/foo/bar')
262
264
  end
263
265
 
264
266
  it "POSTs a new record" do
265
- response.stub(:body => '{"id":"123"}')
266
- subject.stub(:new_record? => true)
267
- client.should_receive(:post).with('/foo/bar','{"foo":"bar"}').and_return(response)
268
- subject.save!("foo" => "bar").should be_true
269
- subject.id.should == "123"
270
- subject.expanded.should be_false
267
+ response = instance_double("Response", body: '{"id":"123"}')
268
+ allow(subject).to receive(:new_record?) { true }
269
+ expect(client).to receive(:post).with('/foo/bar','{"foo":"bar"}').and_return(response)
270
+ expect(subject.save!("foo" => "bar")).to be_truthy
271
+ expect(subject.id).to eq("123")
272
+ expect(subject.expanded).to be_falsey
271
273
  end
272
274
 
273
275
  it "PUTs an existing record" do
274
- response.stub(:body => nil)
275
- subject.stub(:new_record? => false)
276
- client.should_receive(:put).with('/foo/bar','{"foo":"bar"}').and_return(response)
277
- subject.save!("foo" => "bar").should be_true
278
- subject.expanded.should be_false
276
+ response = instance_double("Response", body: nil)
277
+ allow(subject).to receive(:new_record?) { false }
278
+ expect(client).to receive(:put).with('/foo/bar','{"foo":"bar"}').and_return(response)
279
+ expect(subject.save!("foo" => "bar")).to be_truthy
280
+ expect(subject.expanded).to be_falsey
279
281
  end
280
282
 
281
283
  it "throws an exception when an invalid field is set" do
282
- response.stub(:body => '{"errorMessages":["blah"]}', :status => 400)
283
- subject.stub(:new_record? => false)
284
- client.should_receive(:put).with('/foo/bar','{"invalid_field":"foobar"}').and_raise(JIRA::HTTPError.new(response))
285
- lambda do
286
- subject.save!("invalid_field" => "foobar")
287
- end.should raise_error(JIRA::HTTPError)
284
+ response = instance_double("Response", body: '{"errorMessages":["blah"]}', status: 400)
285
+ allow(subject).to receive(:new_record?) { false }
286
+ expect(client).to receive(:put).with('/foo/bar','{"invalid_field":"foobar"}').and_raise(JIRA::HTTPError.new(response))
287
+ expect(lambda{ subject.save!("invalid_field" => "foobar") }).to raise_error(JIRA::HTTPError)
288
288
  end
289
289
  end
290
290
 
@@ -292,27 +292,27 @@ describe JIRA::Base do
292
292
  it "merges hashes correctly when clobber is true (default)" do
293
293
  subject.attrs = {"foo" => {"bar" => "baz"}}
294
294
  subject.set_attrs({"foo" => {"fum" => "dum"}})
295
- subject.foo.should == {"fum" => "dum"}
295
+ expect(subject.foo).to eq({"fum" => "dum"})
296
296
  end
297
297
 
298
298
  it "merges hashes correctly when clobber is false" do
299
299
  subject.attrs = {"foo" => {"bar" => "baz"}}
300
300
  subject.set_attrs({"foo" => {"fum" => "dum"}}, false)
301
- subject.foo.should == {"bar" => "baz", "fum" => "dum"}
301
+ expect(subject.foo).to eq({"bar" => "baz", "fum" => "dum"})
302
302
  end
303
303
  end
304
304
 
305
305
  describe "delete" do
306
306
 
307
307
  before(:each) do
308
- client.should_receive(:delete).with('/foo/bar')
309
- subject.stub(:url => '/foo/bar')
308
+ expect(client).to receive(:delete).with('/foo/bar')
309
+ allow(subject).to receive(:url) { '/foo/bar' }
310
310
  end
311
311
 
312
312
  it "flags itself as deleted" do
313
- subject.deleted?.should be_false
313
+ expect(subject.deleted?).to be_falsey
314
314
  subject.delete
315
- subject.deleted?.should be_true
315
+ expect(subject.deleted?).to be_truthy
316
316
  end
317
317
 
318
318
  it "sends a DELETE request" do
@@ -325,12 +325,12 @@ describe JIRA::Base do
325
325
 
326
326
  it "returns true for new_record? when new object" do
327
327
  subject.attrs['id'] = nil
328
- subject.new_record?.should be_true
328
+ expect(subject.new_record?).to be_truthy
329
329
  end
330
330
 
331
331
  it "returns false for new_record? when id is set" do
332
332
  subject.attrs['id'] = '123'
333
- subject.new_record?.should be_false
333
+ expect(subject.new_record?).to be_falsey
334
334
  end
335
335
 
336
336
  end
@@ -339,11 +339,11 @@ describe JIRA::Base do
339
339
 
340
340
  it "returns true when the response contains errors" do
341
341
  attrs["errors"] = {"invalid" => "Field invalid"}
342
- subject.has_errors?.should be_true
342
+ expect(subject.has_errors?).to be_truthy
343
343
  end
344
344
 
345
345
  it "returns false when the response does not contain any errors" do
346
- subject.has_errors?.should be_false
346
+ expect(subject.has_errors?).to be_falsey
347
347
  end
348
348
 
349
349
  end
@@ -351,37 +351,37 @@ describe JIRA::Base do
351
351
  describe 'url' do
352
352
 
353
353
  before(:each) do
354
- client.stub(:options => {:rest_base_path => '/foo/bar'})
354
+ allow(client).to receive(:options) { {:rest_base_path => '/foo/bar'} }
355
355
  end
356
356
 
357
357
  it "returns self as the URL if set" do
358
358
  pending("Identified bug on real jira instance")
359
359
  attrs['self'] = 'http://foo/bar'
360
- subject.url.should == "http://foo/bar"
360
+ expect(subject.url).to eq("http://foo/bar")
361
361
  end
362
362
 
363
363
  it "generates the URL from id if self not set" do
364
364
  attrs['self'] = nil
365
365
  attrs['id'] = '98765'
366
- subject.url.should == "/foo/bar/deadbeef/98765"
366
+ expect(subject.url).to eq("/foo/bar/deadbeef/98765")
367
367
  end
368
368
 
369
369
  it "generates the URL from collection_path if self and id not set" do
370
370
  attrs['self'] = nil
371
371
  attrs['id'] = nil
372
- subject.url.should == "/foo/bar/deadbeef"
372
+ expect(subject.url).to eq("/foo/bar/deadbeef")
373
373
  end
374
374
 
375
375
  it "has a class method for the collection path" do
376
- JIRA::Resource::Deadbeef.collection_path(client).should == "/foo/bar/deadbeef"
376
+ expect(JIRA::Resource::Deadbeef.collection_path(client)).to eq("/foo/bar/deadbeef")
377
377
  #Should accept an optional prefix (flum in this case)
378
- JIRA::Resource::Deadbeef.collection_path(client, '/flum/').should == "/foo/bar/flum/deadbeef"
378
+ expect(JIRA::Resource::Deadbeef.collection_path(client, '/flum/')).to eq("/foo/bar/flum/deadbeef")
379
379
  end
380
380
 
381
381
  it "has a class method for the singular path" do
382
- JIRA::Resource::Deadbeef.singular_path(client, 'abc123').should == "/foo/bar/deadbeef/abc123"
382
+ expect(JIRA::Resource::Deadbeef.singular_path(client, 'abc123')).to eq("/foo/bar/deadbeef/abc123")
383
383
  #Should accept an optional prefix (flum in this case)
384
- JIRA::Resource::Deadbeef.singular_path(client, 'abc123', '/flum/').should == "/foo/bar/flum/deadbeef/abc123"
384
+ expect(JIRA::Resource::Deadbeef.singular_path(client, 'abc123', '/flum/')).to eq("/foo/bar/flum/deadbeef/abc123")
385
385
  end
386
386
  end
387
387
 
@@ -389,22 +389,22 @@ describe JIRA::Base do
389
389
  subject.attrs['foo'] = 'bar'
390
390
  subject.attrs['dead'] = 'beef'
391
391
 
392
- subject.to_s.should match(/#<JIRA::Resource::Deadbeef:\d+ @attrs=#{Regexp.quote(attrs.inspect)}>/)
392
+ expect(subject.to_s).to match(/#<JIRA::Resource::Deadbeef:\d+ @attrs=#{Regexp.quote(attrs.inspect)}>/)
393
393
  end
394
394
 
395
395
  it "returns the key attribute" do
396
- subject.class.key_attribute.should == :id
396
+ expect(subject.class.key_attribute).to eq(:id)
397
397
  end
398
398
 
399
399
  it "returns the key value" do
400
400
  subject.attrs['id'] = '123'
401
- subject.key_value.should == '123'
401
+ expect(subject.key_value).to eq('123')
402
402
  end
403
403
 
404
404
  it "converts to json" do
405
405
  subject.attrs = {"foo" => "bar","dead" => "beef"}
406
406
 
407
- subject.to_json.should == subject.attrs.to_json
407
+ expect(subject.to_json).to eq(subject.attrs.to_json)
408
408
  end
409
409
 
410
410
  describe "extract attrs from response" do
@@ -412,42 +412,39 @@ describe JIRA::Base do
412
412
  subject { JIRA::Resource::Deadbeef.new(client, :attrs => {}) }
413
413
 
414
414
  it "sets the attrs from a response" do
415
- response = double()
416
- response.stub(:body).and_return('{"foo":"bar"}')
415
+ response = instance_double("Response", body: '{"foo":"bar"}')
417
416
 
418
- subject.set_attrs_from_response(response).should == {'foo' => 'bar'}
419
- subject.foo.should == "bar"
417
+ expect(subject.set_attrs_from_response(response)).to eq({'foo' => 'bar'})
418
+ expect(subject.foo).to eq("bar")
420
419
  end
421
420
 
422
421
  it "doesn't clobber existing attrs not in response" do
423
- response = double()
424
- response.stub(:body).and_return('{"foo":"bar"}')
422
+ response = instance_double("Response", body: '{"foo":"bar"}')
425
423
 
426
424
  subject.attrs = {'flum' => 'flar'}
427
- subject.set_attrs_from_response(response).should == {'foo' => 'bar'}
428
- subject.foo.should == "bar"
429
- subject.flum.should == "flar"
425
+ expect(subject.set_attrs_from_response(response)).to eq({'foo' => 'bar'})
426
+ expect(subject.foo).to eq("bar")
427
+ expect(subject.flum).to eq("flar")
430
428
  end
431
429
 
432
430
  it "handles nil response body" do
433
- response = double()
434
- response.stub(:body).and_return(nil)
431
+ response = instance_double("Response", body: nil)
435
432
 
436
433
  subject.attrs = {'flum' => 'flar'}
437
- subject.set_attrs_from_response(response).should be_nil
438
- subject.flum.should == 'flar'
434
+ expect(subject.set_attrs_from_response(response)).to be_nil
435
+ expect(subject.flum).to eq('flar')
439
436
  end
440
437
  end
441
438
 
442
439
  describe "nesting" do
443
440
 
444
441
  it "defaults collection_attributes_are_nested to false" do
445
- JIRA::Resource::Deadbeef.collection_attributes_are_nested.should be_false
442
+ expect(JIRA::Resource::Deadbeef.collection_attributes_are_nested).to be_falsey
446
443
  end
447
444
 
448
445
  it "allows collection_attributes_are_nested to be set" do
449
446
  JIRA::Resource::Deadbeef.nested_collections true
450
- JIRA::Resource::Deadbeef.collection_attributes_are_nested.should be_true
447
+ expect(JIRA::Resource::Deadbeef.collection_attributes_are_nested).to be_truthy
451
448
  end
452
449
 
453
450
  end
@@ -457,23 +454,23 @@ describe JIRA::Base do
457
454
  subject { JIRA::Resource::HasManyExample.new(client, :attrs => {'deadbeefs' => [{'id' => '123'}]}) }
458
455
 
459
456
  it "returns a collection of instances for has_many relationships" do
460
- subject.deadbeefs.class.should == JIRA::HasManyProxy
461
- subject.deadbeefs.length.should == 1
457
+ expect(subject.deadbeefs.class).to eq(JIRA::HasManyProxy)
458
+ expect(subject.deadbeefs.length).to eq(1)
462
459
  subject.deadbeefs.each do |deadbeef|
463
- deadbeef.class.should == JIRA::Resource::Deadbeef
460
+ expect(deadbeef.class).to eq(JIRA::Resource::Deadbeef)
464
461
  end
465
462
  end
466
463
 
467
464
  it "returns an empty collection for empty has_many relationships" do
468
465
  subject = JIRA::Resource::HasManyExample.new(client)
469
- subject.deadbeefs.length.should == 0
466
+ expect(subject.deadbeefs.length).to eq(0)
470
467
  end
471
468
 
472
469
  it "allows the has_many attributes to be nested inside another attribute" do
473
470
  subject = JIRA::Resource::HasManyExample.new(client, :attrs => {'nested' => {'brunchmuffins' => [{'id' => '123'},{'id' => '456'}]}})
474
- subject.brunchmuffins.length.should == 2
471
+ expect(subject.brunchmuffins.length).to eq(2)
475
472
  subject.brunchmuffins.each do |brunchmuffin|
476
- brunchmuffin.class.should == JIRA::Resource::Deadbeef
473
+ expect(brunchmuffin.class).to eq(JIRA::Resource::Deadbeef)
477
474
  end
478
475
  end
479
476
 
@@ -481,9 +478,9 @@ describe JIRA::Base do
481
478
  subject = JIRA::Resource::HasManyExample.new(client, :attrs => {'nested' => {
482
479
  'breakfastscone' => { 'breakfastscones' => [{'id' => '123'},{'id' => '456'}] }
483
480
  }})
484
- subject.breakfastscones.length.should == 2
481
+ expect(subject.breakfastscones.length).to eq(2)
485
482
  subject.breakfastscones.each do |breakfastscone|
486
- breakfastscone.class.should == JIRA::Resource::Deadbeef
483
+ expect(breakfastscone.class).to eq(JIRA::Resource::Deadbeef)
487
484
  end
488
485
  end
489
486
 
@@ -491,20 +488,20 @@ describe JIRA::Base do
491
488
  subject = JIRA::Resource::HasManyExample.new(client, :attrs => {
492
489
  'nested' => {}
493
490
  })
494
- subject.breakfastscones.length.should == 0
491
+ expect(subject.breakfastscones.length).to eq(0)
495
492
  end
496
493
 
497
494
  it "allows the attribute key to be specified" do
498
495
  subject = JIRA::Resource::HasManyExample.new(client, :attrs => {'irregularlyNamedThings' => [{'id' => '123'},{'id' => '456'}]})
499
- subject.irregularly_named_things.length.should == 2
496
+ expect(subject.irregularly_named_things.length).to eq(2)
500
497
  subject.irregularly_named_things.each do |thing|
501
- thing.class.should == JIRA::Resource::Deadbeef
498
+ expect(thing.class).to eq(JIRA::Resource::Deadbeef)
502
499
  end
503
500
  end
504
501
 
505
502
  it "can build child instances" do
506
503
  deadbeef = subject.deadbeefs.build
507
- deadbeef.class.should == JIRA::Resource::Deadbeef
504
+ expect(deadbeef.class).to eq(JIRA::Resource::Deadbeef)
508
505
  end
509
506
 
510
507
  end
@@ -514,39 +511,39 @@ describe JIRA::Base do
514
511
  subject { JIRA::Resource::HasOneExample.new(client, :attrs => {'deadbeef' => {'id' => '123'}}) }
515
512
 
516
513
  it "returns an instance for a has one relationship" do
517
- subject.deadbeef.class.should == JIRA::Resource::Deadbeef
518
- subject.deadbeef.id.should == '123'
514
+ expect(subject.deadbeef.class).to eq(JIRA::Resource::Deadbeef)
515
+ expect(subject.deadbeef.id).to eq('123')
519
516
  end
520
517
 
521
518
  it "returns nil when resource attribute is nonexistent" do
522
519
  subject = JIRA::Resource::HasOneExample.new(client)
523
- subject.deadbeef.should be_nil
520
+ expect(subject.deadbeef).to be_nil
524
521
  end
525
522
 
526
523
  it "returns an instance with a different class name to the attribute name" do
527
524
  subject = JIRA::Resource::HasOneExample.new(client, :attrs => {'muffin' => {'id' => '123'}})
528
- subject.muffin.class.should == JIRA::Resource::Deadbeef
529
- subject.muffin.id.should == '123'
525
+ expect(subject.muffin.class).to eq(JIRA::Resource::Deadbeef)
526
+ expect(subject.muffin.id).to eq('123')
530
527
  end
531
528
 
532
529
  it "allows the has_one attributes to be nested inside another attribute" do
533
530
  subject = JIRA::Resource::HasOneExample.new(client, :attrs => {'nested' => {'brunchmuffin' => {'id' => '123'}}})
534
- subject.brunchmuffin.class.should == JIRA::Resource::Deadbeef
535
- subject.brunchmuffin.id.should == '123'
531
+ expect(subject.brunchmuffin.class).to eq(JIRA::Resource::Deadbeef)
532
+ expect(subject.brunchmuffin.id).to eq('123')
536
533
  end
537
534
 
538
535
  it "allows it to be deeply nested" do
539
536
  subject = JIRA::Resource::HasOneExample.new(client, :attrs => {'nested' => {
540
537
  'breakfastscone' => { 'breakfastscone' => {'id' => '123'} }
541
538
  }})
542
- subject.breakfastscone.class.should == JIRA::Resource::Deadbeef
543
- subject.breakfastscone.id.should == '123'
539
+ expect(subject.breakfastscone.class).to eq(JIRA::Resource::Deadbeef)
540
+ expect(subject.breakfastscone.id).to eq('123')
544
541
  end
545
542
 
546
543
  it "allows the attribute key to be specified" do
547
544
  subject = JIRA::Resource::HasOneExample.new(client, :attrs => {'irregularlyNamedThing' => {'id' => '123'}})
548
- subject.irregularly_named_thing.class.should == JIRA::Resource::Deadbeef
549
- subject.irregularly_named_thing.id.should == '123'
545
+ expect(subject.irregularly_named_thing.class).to eq(JIRA::Resource::Deadbeef)
546
+ expect(subject.irregularly_named_thing.id).to eq('123')
550
547
  end
551
548
 
552
549
  end
@@ -562,24 +559,24 @@ describe JIRA::Base do
562
559
  subject { JIRA::Resource::BelongsToExample.new(client, :attrs => {'id' => '123'}, :deadbeef => deadbeef) }
563
560
 
564
561
  it "sets up an accessor for the belongs to relationship" do
565
- subject.deadbeef.should == deadbeef
562
+ expect(subject.deadbeef).to eq(deadbeef)
566
563
  end
567
564
 
568
565
  it "raises an exception when initialized without a belongs_to instance" do
569
- lambda do
566
+ expect(lambda {
570
567
  JIRA::Resource::BelongsToExample.new(client, :attrs => {'id' => '123'})
571
- end.should raise_exception(ArgumentError,"Required option :deadbeef missing")
568
+ }).to raise_exception(ArgumentError,"Required option :deadbeef missing")
572
569
  end
573
570
 
574
571
  it "returns the right url" do
575
- client.stub(:options => { :rest_base_path => "/foo" })
576
- subject.url.should == "/foo/deadbeef/999/belongstoexample/123"
572
+ allow(client).to receive(:options) { { :rest_base_path => "/foo" } }
573
+ expect(subject.url).to eq("/foo/deadbeef/999/belongstoexample/123")
577
574
  end
578
575
 
579
576
  it "can be initialized with an instance or a key value" do
580
- client.stub(:options => { :rest_base_path => "/foo" })
577
+ allow(client).to receive(:options) { { :rest_base_path => "/foo" } }
581
578
  subject = JIRA::Resource::BelongsToExample.new(client, :attrs => {'id' => '123'}, :deadbeef_id => '987')
582
- subject.url.should == "/foo/deadbeef/987/belongstoexample/123"
579
+ expect(subject.url).to eq("/foo/deadbeef/987/belongstoexample/123")
583
580
  end
584
581
 
585
582
  end