harpy 1.0.0 → 2.0.0.preview1

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.
@@ -4,13 +4,12 @@ describe Harpy::Resource do
4
4
  describe ".from_url(hash)" do
5
5
  let(:company_url) { "http://localhost/company/1" }
6
6
  let(:json_response) { %Q|{"name": "Harpy ltd", "link": [{"rel": "self", "href": "#{company_url}"}]}| }
7
- let(:success_response) { Typhoeus::Response.new :code => 200, :body => json_response}
8
7
  it "queries multiple resources in parallel and return instances" do
9
- Typhoeus.stub(company_url, method: :get){ success_response }
8
+ stub_request(:get, company_url).to_return(status: 200, body: json_response)
10
9
  responses = Harpy::Resource.from_url({ Harpy::Spec::Company => [company_url] })
11
- responses.should have(1).keys
12
- responses[Harpy::Spec::Company].should have(1).item
13
- responses[Harpy::Spec::Company].first.name.should == "Harpy ltd"
10
+ expect(responses.size).to eq(1)
11
+ expect(responses[Harpy::Spec::Company].size).to eq(1)
12
+ expect(responses[Harpy::Spec::Company].first.name).to eq("Harpy ltd")
14
13
  end
15
14
  end
16
15
  end
@@ -35,7 +34,7 @@ module Harpy
35
34
  super
36
35
  end
37
36
  def check_lastname
38
- !!lastname
37
+ throw :abort unless lastname
39
38
  end
40
39
  def callback_before_save
41
40
  @callbacks << :save
@@ -59,7 +58,7 @@ describe "class including Harpy::Resource" do
59
58
  context "called with only one url" do
60
59
  let(:url){ "http://localhost/company/1" }
61
60
  it "is a properly filled-in instance of Harpy::Spec::Company on success" do
62
- response = Typhoeus::Response.new :code => 200, :body => <<-eos
61
+ response = httpx_response :code => 200, :body => <<-eos
63
62
  {
64
63
  "name": "Harpy Ltd",
65
64
  "link": [
@@ -67,21 +66,21 @@ describe "class including Harpy::Resource" do
67
66
  ]
68
67
  }
69
68
  eos
70
- Harpy.client.should_receive(:get).with(url).and_return response
69
+ expect(Harpy.client).to receive(:get).with(url).and_return response
71
70
  result = Harpy::Spec::Company.from_url url
72
- result.should be_kind_of Harpy::Spec::Company
73
- result.name.should == "Harpy Ltd"
74
- result.link("self").should == url
71
+ expect(result).to be_kind_of Harpy::Spec::Company
72
+ expect(result.name).to eq("Harpy Ltd")
73
+ expect(result.link("self")).to eq(url)
75
74
  end
76
75
  it "is nil when not found" do
77
- response = Typhoeus::Response.new :code => 404
78
- Harpy.client.should_receive(:get).with(url).and_return response
79
- Harpy::Spec::Company.from_url(url).should be_nil
76
+ response = httpx_response :code => 404
77
+ expect(Harpy.client).to receive(:get).with(url).and_return response
78
+ expect(Harpy::Spec::Company.from_url(url)).to be_nil
80
79
  end
81
80
  it "delegates response code != 200 or 404 to client" do
82
- response = Typhoeus::Response.new :code => 500
83
- Harpy.client.should_receive(:get).with(url).and_return response
84
- Harpy.client.should_receive(:invalid_code).with response
81
+ response = httpx_response :code => 500
82
+ expect(Harpy.client).to receive(:get).with(url).and_return response
83
+ expect(Harpy.client).to receive(:invalid_code).with response
85
84
  Harpy::Spec::Company.from_url(url)
86
85
  end
87
86
  end
@@ -89,7 +88,7 @@ describe "class including Harpy::Resource" do
89
88
  let(:url1){ "http://localhost/company/1" }
90
89
  let(:url2){ "http://localhost/company/2" }
91
90
  it "is a properly filled-in instance of Harpy::Spec::Company on success" do
92
- response1 = Typhoeus::Response.new :code => 200, :body => <<-eos
91
+ response1 = httpx_response :code => 200, :body => <<-eos
93
92
  {
94
93
  "name": "Harpy Ltd",
95
94
  "link": [
@@ -97,7 +96,7 @@ describe "class including Harpy::Resource" do
97
96
  ]
98
97
  }
99
98
  eos
100
- response2 = Typhoeus::Response.new :code => 200, :body => <<-eos
99
+ response2 = httpx_response :code => 200, :body => <<-eos
101
100
  {
102
101
  "name": "Harpy Inc",
103
102
  "link": [
@@ -105,25 +104,25 @@ describe "class including Harpy::Resource" do
105
104
  ]
106
105
  }
107
106
  eos
108
- Typhoeus.stub(url1, method: :get){ response1 }
109
- Typhoeus.stub(url2, method: :get){ response2 }
107
+ stub_request(:get, url1).to_return(status: 200, body: response1.body.to_s)
108
+ stub_request(:get, url2).to_return(status: 200, body: response2.body.to_s)
110
109
  results = Harpy::Spec::Company.from_url [url1, url2]
111
- results.should have(2).items
112
- results[0].should be_kind_of Harpy::Spec::Company
113
- results[0].name.should == "Harpy Ltd"
114
- results[0].link("self").should == url1
115
- results[1].should be_kind_of Harpy::Spec::Company
116
- results[1].name.should == "Harpy Inc"
117
- results[1].link("self").should == url2
110
+ expect(results.size).to eq(2)
111
+ expect(results[0]).to be_kind_of Harpy::Spec::Company
112
+ expect(results[0].name).to eq("Harpy Ltd")
113
+ expect(results[0].link("self")).to eq(url1)
114
+ expect(results[1]).to be_kind_of Harpy::Spec::Company
115
+ expect(results[1].name).to eq("Harpy Inc")
116
+ expect(results[1].link("self")).to eq(url2)
118
117
  end
119
118
  end
120
119
  end
121
120
  describe ".from_urn(urn)" do
122
121
  context "when entry point is not set" do
123
122
  it "raises Harpy::EntryPointRequired" do
124
- lambda{
123
+ expect{
125
124
  Harpy::Spec::Company.from_urn("urn:harpy:company:1")
126
- }.should raise_error Harpy::EntryPointRequired
125
+ }.to raise_error Harpy::EntryPointRequired
127
126
  end
128
127
  end
129
128
  context "when entry point is set" do
@@ -132,38 +131,38 @@ describe "class including Harpy::Resource" do
132
131
  it "asks Harpy.entry_point to convert urn to url then call .from_url" do
133
132
  # urn:harpy:company:1 -> http://localhost/company/1
134
133
  Harpy.entry_point = double
135
- Harpy.entry_point.should_receive(:urn).with(urn).and_return url
134
+ expect(Harpy.entry_point).to receive(:urn).with(urn).and_return url
136
135
 
137
136
  # http://localhost/company/1 -> Harpy::Spec::Company instance
138
- Harpy::Spec::Company.should_receive(:from_url).with(url).and_return(expected = double)
139
- Harpy::Spec::Company.from_urn(urn).should be expected
137
+ expect(Harpy::Spec::Company).to receive(:from_url).with(url).and_return(expected = double)
138
+ expect(Harpy::Spec::Company.from_urn(urn)).to be expected
140
139
  end
141
140
  it "is nil if urn is not found" do
142
141
  # urn:harpy:company:1 -> nil
143
142
  Harpy.entry_point = double
144
- Harpy.entry_point.should_receive(:urn).with(urn)
143
+ expect(Harpy.entry_point).to receive(:urn).with(urn)
145
144
 
146
- Harpy::Spec::Company.from_urn(urn).should be_nil
145
+ expect(Harpy::Spec::Company.from_urn(urn)).to be_nil
147
146
  end
148
147
  end
149
148
  end
150
149
  describe ".from_id(id)" do
151
150
  context "when urn has not been overriden" do
152
151
  it "raises NotImplementedError" do
153
- lambda{
152
+ expect{
154
153
  Harpy::Spec::Company.from_id(1)
155
- }.should raise_error NotImplementedError
154
+ }.to raise_error NotImplementedError
156
155
  end
157
156
  end
158
157
  context "when urn has been overriden but entry point is not set" do
159
158
  let(:urn) { "urn:harpy:company:1" }
160
159
  it "raises Harpy::EntryPointRequired" do
161
160
  # 1 -> urn:harpy:company:1
162
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
161
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
163
162
 
164
- lambda{
163
+ expect{
165
164
  Harpy::Spec::Company.from_id(1)
166
- }.should raise_error Harpy::EntryPointRequired
165
+ }.to raise_error Harpy::EntryPointRequired
167
166
  end
168
167
  end
169
168
  context "when entry point is set and urn has been overriden" do
@@ -171,25 +170,25 @@ describe "class including Harpy::Resource" do
171
170
  let(:url) { "http://localhost/company/1" }
172
171
  it "asks Harpy.entry_point to convert urn to url then call .from_url" do
173
172
  # 1 -> urn:harpy:company:1
174
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
173
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
175
174
 
176
175
  # urn:harpy:company:1 -> http://localhost/company/1
177
176
  Harpy.entry_point = double
178
- Harpy.entry_point.should_receive(:urn).with(urn).and_return url
177
+ expect(Harpy.entry_point).to receive(:urn).with(urn).and_return url
179
178
 
180
179
  # http://localhost/company/1 -> Harpy::Spec::Company instance
181
- Harpy::Spec::Company.should_receive(:from_url).with(url).and_return(expected = double)
182
- Harpy::Spec::Company.from_id(1).should be expected
180
+ expect(Harpy::Spec::Company).to receive(:from_url).with(url).and_return(expected = double)
181
+ expect(Harpy::Spec::Company.from_id(1)).to be expected
183
182
  end
184
183
  it "is nil if urn is not found" do
185
184
  # 1 -> urn:harpy:company:1
186
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
185
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
187
186
 
188
187
  # urn:harpy:company:1 -> nil
189
188
  Harpy.entry_point = double
190
- Harpy.entry_point.should_receive(:urn).with(urn)
189
+ expect(Harpy.entry_point).to receive(:urn).with(urn)
191
190
 
192
- Harpy::Spec::Company.from_id(1).should be_nil
191
+ expect(Harpy::Spec::Company.from_id(1)).to be_nil
193
192
  end
194
193
  end
195
194
  end
@@ -197,20 +196,20 @@ describe "class including Harpy::Resource" do
197
196
  context "called with only one url" do
198
197
  let(:url){ "http://localhost/company/1" }
199
198
  it "is true on success" do
200
- response = Typhoeus::Response.new :code => 204
201
- Harpy.client.should_receive(:delete).with(url).and_return response
199
+ response = httpx_response :code => 204
200
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
202
201
  result = Harpy::Spec::Company.delete_from_url url
203
- result.should be_true
202
+ expect(result).to be_truthy
204
203
  end
205
204
  it "is false when not found" do
206
- response = Typhoeus::Response.new :code => 404
207
- Harpy.client.should_receive(:delete).with(url).and_return response
208
- Harpy::Spec::Company.delete_from_url(url).should be_false
205
+ response = httpx_response :code => 404
206
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
207
+ expect(Harpy::Spec::Company.delete_from_url(url)).to be_falsey
209
208
  end
210
209
  it "delegates response code != 204 or 404 to client" do
211
- response = Typhoeus::Response.new :code => 500
212
- Harpy.client.should_receive(:delete).with(url).and_return response
213
- Harpy.client.should_receive(:invalid_code).with response
210
+ response = httpx_response :code => 500
211
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
212
+ expect(Harpy.client).to receive(:invalid_code).with response
214
213
  Harpy::Spec::Company.delete_from_url url
215
214
  end
216
215
  end
@@ -218,9 +217,9 @@ describe "class including Harpy::Resource" do
218
217
  describe ".delete_from_urn(urn)" do
219
218
  context "when entry point is not set" do
220
219
  it "raises Harpy::EntryPointRequired" do
221
- lambda{
220
+ expect{
222
221
  Harpy::Spec::Company.delete_from_urn("urn:harpy:company:1")
223
- }.should raise_error Harpy::EntryPointRequired
222
+ }.to raise_error Harpy::EntryPointRequired
224
223
  end
225
224
  end
226
225
  context "when entry point is set" do
@@ -229,38 +228,38 @@ describe "class including Harpy::Resource" do
229
228
  it "asks Harpy.entry_point to convert urn to url then call .from_url" do
230
229
  # urn:harpy:company:1 -> http://localhost/company/1
231
230
  Harpy.entry_point = double
232
- Harpy.entry_point.should_receive(:urn).with(urn).and_return url
231
+ expect(Harpy.entry_point).to receive(:urn).with(urn).and_return url
233
232
 
234
233
  # http://localhost/company/1 -> Harpy::Spec::Company instance
235
- Harpy::Spec::Company.should_receive(:delete_from_url).with(url).and_return(expected = double)
236
- Harpy::Spec::Company.delete_from_urn(urn).should be expected
234
+ expect(Harpy::Spec::Company).to receive(:delete_from_url).with(url).and_return(expected = double)
235
+ expect(Harpy::Spec::Company.delete_from_urn(urn)).to be expected
237
236
  end
238
237
  it "is nil if urn is not found" do
239
238
  # urn:harpy:company:1 -> nil
240
239
  Harpy.entry_point = double
241
- Harpy.entry_point.should_receive(:urn).with(urn)
240
+ expect(Harpy.entry_point).to receive(:urn).with(urn)
242
241
 
243
- Harpy::Spec::Company.delete_from_urn(urn).should be_false
242
+ expect(Harpy::Spec::Company.delete_from_urn(urn)).to be_falsey
244
243
  end
245
244
  end
246
245
  end
247
246
  describe ".delete_from_id(id)" do
248
247
  context "when urn has not been overriden" do
249
248
  it "raises NotImplementedError" do
250
- lambda{
249
+ expect{
251
250
  Harpy::Spec::Company.delete_from_id(1)
252
- }.should raise_error NotImplementedError
251
+ }.to raise_error NotImplementedError
253
252
  end
254
253
  end
255
254
  context "when urn has been overriden but entry point is not set" do
256
255
  let(:urn) { "urn:harpy:company:1" }
257
256
  it "raises Harpy::EntryPointRequired" do
258
257
  # 1 -> urn:harpy:company:1
259
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
258
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
260
259
 
261
- lambda{
260
+ expect{
262
261
  Harpy::Spec::Company.delete_from_id(1)
263
- }.should raise_error Harpy::EntryPointRequired
262
+ }.to raise_error Harpy::EntryPointRequired
264
263
  end
265
264
  end
266
265
  context "when entry point is set and urn has been overriden" do
@@ -268,48 +267,48 @@ describe "class including Harpy::Resource" do
268
267
  let(:url) { "http://localhost/company/1" }
269
268
  it "asks Harpy.entry_point to convert urn to url then call .from_url" do
270
269
  # 1 -> urn:harpy:company:1
271
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
270
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
272
271
 
273
272
  # urn:harpy:company:1 -> http://localhost/company/1
274
273
  Harpy.entry_point = double
275
- Harpy.entry_point.should_receive(:urn).with(urn).and_return url
274
+ expect(Harpy.entry_point).to receive(:urn).with(urn).and_return url
276
275
 
277
276
  # http://localhost/company/1 -> Harpy::Spec::Company instance
278
- Harpy::Spec::Company.should_receive(:delete_from_url).with(url).and_return(expected = double)
279
- Harpy::Spec::Company.delete_from_id(1).should be expected
277
+ expect(Harpy::Spec::Company).to receive(:delete_from_url).with(url).and_return(expected = double)
278
+ expect(Harpy::Spec::Company.delete_from_id(1)).to be expected
280
279
  end
281
280
  it "is nil if urn is not found" do
282
281
  # 1 -> urn:harpy:company:1
283
- Harpy::Spec::Company.should_receive(:urn).with(1).and_return urn
282
+ expect(Harpy::Spec::Company).to receive(:urn).with(1).and_return urn
284
283
 
285
284
  # urn:harpy:company:1 -> nil
286
285
  Harpy.entry_point = double
287
- Harpy.entry_point.should_receive(:urn).with(urn)
286
+ expect(Harpy.entry_point).to receive(:urn).with(urn)
288
287
 
289
- Harpy::Spec::Company.delete_from_id(1).should be_false
288
+ expect(Harpy::Spec::Company.delete_from_id(1)).to be_falsey
290
289
  end
291
290
  end
292
291
  end
293
292
  describe ".urn(id)" do
294
293
  it "raises NotImplementedError" do
295
- lambda{
294
+ expect{
296
295
  Harpy::Spec::Company.urn(1)
297
- }.should raise_error NotImplementedError
296
+ }.to raise_error NotImplementedError
298
297
  end
299
298
  end
300
299
  describe ".resource_name" do
301
300
  it "defaults to underscored class name" do
302
- Harpy::Spec::Company.resource_name.should == "harpy/spec/company"
301
+ expect(Harpy::Spec::Company.resource_name).to eq("harpy/spec/company")
303
302
  end
304
303
  end
305
304
  describe ".search(conditions)" do
306
305
  let(:url){ "http://localhost/company" }
307
306
  before do
308
307
  Harpy.entry_point = double
309
- Harpy.entry_point.should_receive(:resource_url).with("harpy/spec/company").and_return url
308
+ expect(Harpy.entry_point).to receive(:resource_url).with("harpy/spec/company").and_return url
310
309
  end
311
310
  it "return properly filled instances on 200" do
312
- response = Typhoeus::Response.new :code => 200, :body => <<-eos
311
+ response = httpx_response :code => 200, :body => <<-eos
313
312
  {
314
313
  "harpy/spec/company": [
315
314
  {
@@ -325,50 +324,50 @@ describe "class including Harpy::Resource" do
325
324
  ]
326
325
  }
327
326
  eos
328
- Harpy.client.should_receive(:get).with(url, :params => {"firstname" => "Anthony"}).and_return response
327
+ expect(Harpy.client).to receive(:get).with(url, :params => {"firstname" => "Anthony"}).and_return response
329
328
  companies = Harpy::Spec::Company.search "firstname" => "Anthony"
330
- companies.should be_kind_of Harpy::Collection
331
- companies.should have(1).item
332
- companies.should have(1).items
333
- companies.first.should be_kind_of Harpy::Spec::Company
334
- companies.first.firstname.should == "Anthony"
335
- companies.first.id.should == "1"
336
- companies.url.should == url
337
- companies.each do |company|
338
- company.firstname.should == "Anthony"
339
- end.should be_kind_of Array
340
- companies.each.should be_kind_of(defined?(Enumerator) ? Enumerator : Enumerable::Enumerator)
341
- companies.to_a.should == [companies.first]
342
- companies.detect{ true }.should be companies.first
343
- companies.should be_present
344
- companies.should_not be_blank
329
+ expect(companies).to be_kind_of Harpy::Collection
330
+ expect(companies.size).to eq(1)
331
+ expect(companies.size).to eq(1)
332
+ expect(companies.first).to be_kind_of Harpy::Spec::Company
333
+ expect(companies.first.firstname).to eq("Anthony")
334
+ expect(companies.first.id).to eq("1")
335
+ expect(companies.url).to eq(url)
336
+ expect(companies.each do |company|
337
+ expect(company.firstname).to eq("Anthony")
338
+ end).to be_kind_of Array
339
+ expect(companies.each).to be_kind_of(defined?(Enumerator) ? Enumerator : Enumerable::Enumerator)
340
+ expect(companies.to_a).to eq([companies.first])
341
+ expect(companies.detect{ true }).to be companies.first
342
+ expect(companies.present?).to be true
343
+ expect(companies.blank?).not_to be true
345
344
  companies.replace []
346
- companies.should_not be_present
347
- companies.should be_blank
345
+ expect(companies.present?).not_to be true
346
+ expect(companies.blank?).to be true
348
347
  end
349
348
  it "delegates other response codes to client" do
350
- response = Typhoeus::Response.new :code => 500
351
- Harpy.client.should_receive(:get).with(url, :params => {}).and_return response
352
- Harpy.client.should_receive(:invalid_code).with response
349
+ response = httpx_response :code => 500
350
+ expect(Harpy.client).to receive(:get).with(url, :params => {}).and_return response
351
+ expect(Harpy.client).to receive(:invalid_code).with response
353
352
  Harpy::Spec::Company.search
354
353
  end
355
354
  end
356
355
  describe ".with_url(url)" do
357
356
  let(:url){ "http://localhost/user/1/company" }
358
357
  it "overrides url used for searches" do
359
- response = Typhoeus::Response.new :code => 500
360
- Harpy.client.should_receive(:get).with(url, :params => {}).and_return response
361
- Harpy.client.should_receive(:invalid_code).with response
358
+ response = httpx_response :code => 500
359
+ expect(Harpy.client).to receive(:get).with(url, :params => {}).and_return response
360
+ expect(Harpy.client).to receive(:invalid_code).with response
362
361
  Harpy::Spec::Company.with_url(url) do
363
362
  Harpy::Spec::Company.search
364
363
  end
365
364
  end
366
365
  it "can be nested" do
367
366
  url2 = "http://localhost/user/2/company"
368
- response = Typhoeus::Response.new :code => 500
369
- Harpy.client.should_receive(:get).ordered.with(url2, :params => {}).and_return response
370
- Harpy.client.should_receive(:get).ordered.with(url, :params => {}).and_return response
371
- Harpy.client.should_receive(:invalid_code).twice.with response
367
+ response = httpx_response :code => 500
368
+ expect(Harpy.client).to receive(:get).ordered.with(url2, :params => {}).and_return response
369
+ expect(Harpy.client).to receive(:get).ordered.with(url, :params => {}).and_return response
370
+ expect(Harpy.client).to receive(:invalid_code).twice.with response
372
371
  Harpy::Spec::Company.with_url(url) do
373
372
  Harpy::Spec::Company.with_url(url2) do
374
373
  Harpy::Spec::Company.search
@@ -380,43 +379,43 @@ describe "class including Harpy::Resource" do
380
379
  describe "mass assignment" do
381
380
  it "sets any attribute on initialization" do
382
381
  company = Harpy::Spec::Company.new "name" => "Harpy Ltd"
383
- company.name.should == "Harpy Ltd"
382
+ expect(company.name).to eq("Harpy Ltd")
384
383
  end
385
384
  it "initialization works with string keys only" do
386
385
  company = Harpy::Spec::Company.new :name => "Harpy Ltd"
387
- company.name.should be_nil
386
+ expect(company.name).to be_nil
388
387
  end
389
388
  it "#attributes=(attrs) merges new attributes with previous ones" do
390
389
  company = Harpy::Spec::Company.new "name" => "Harpy Ltd", "deleted" => false
391
390
  company.attributes = {"name" => "Harpy Inc", "custom" => true}
392
- company.name.should eql "Harpy Inc"
393
- company.deleted.should be_false
394
- company.custom.should be_true
391
+ expect(company.name).to eql "Harpy Inc"
392
+ expect(company.deleted).to be_falsey
393
+ expect(company.custom).to be_truthy
395
394
  end
396
395
  it "#attributes=(attrs) works with string keys only" do
397
396
  company = Harpy::Spec::Company.new "name" => "Harpy Ltd"
398
397
  company.attributes = {:name => "Harpy Inc"}
399
- company.name.should eql "Harpy Ltd"
398
+ expect(company.name).to eql "Harpy Ltd"
400
399
  end
401
400
  it "doesn't define writers for each attribute" do
402
401
  company = Harpy::Spec::Company.new "name" => "Harpy Ltd"
403
- lambda{ company.name = "test" }.should raise_error NoMethodError
404
- lambda{ company[1] }.should raise_error NoMethodError
402
+ expect{ company.name = "test" }.to raise_error NoMethodError
403
+ expect{ company[1] }.to raise_error NoMethodError
405
404
  end
406
405
  it "allows accessing undefined attributes when not persisted" do
407
- subject.name.should be_nil
406
+ expect(subject.name).to be_nil
408
407
  end
409
408
  it "doesn't allows accessing undefined attributes when not persisted" do
410
- subject.should_receive(:persisted?).and_return true
411
- lambda{ subject.name }.should raise_error NoMethodError
409
+ expect(subject).to receive(:persisted?).and_return true
410
+ expect{ subject.name }.to raise_error NoMethodError
412
411
  end
413
412
  it "use existing setters if available" do
414
413
  company = Harpy::Spec::Company.new "tax_id" => "123"
415
- company.tax_id.should == "123"
416
- company.as_json.should == {}
414
+ expect(company.tax_id).to eq("123")
415
+ expect(company.as_json).to eq({})
417
416
  company.attributes = {:tax_id => 123}
418
- company.tax_id.should == 123
419
- company.as_json.should == {}
417
+ expect(company.tax_id).to eq(123)
418
+ expect(company.as_json).to eq({})
420
419
  end
421
420
  end
422
421
  describe "advanced attribute readers" do
@@ -424,111 +423,111 @@ describe "class including Harpy::Resource" do
424
423
  subject{ Harpy::Spec::Company.new "link" => [{"rel" => "self", "href" => url}] }
425
424
  describe "#link(rel)" do
426
425
  it "searches link with matching rel and return href" do
427
- subject.link("self").should == url
426
+ expect(subject.link("self")).to eq(url)
428
427
  end
429
428
  it "works with symbols too" do
430
- subject.link(:self).should == url
429
+ expect(subject.link(:self)).to eq(url)
431
430
  end
432
431
  it "is nil if no matching link can be found" do
433
- subject.link("user").should be_nil
432
+ expect(subject.link("user")).to be_nil
434
433
  end
435
434
  end
436
435
  describe "#url" do
437
436
  it "searches url to self inside links" do
438
- subject.should_receive(:link).with("self").and_return (expected = double)
439
- subject.url.should be expected
437
+ expect(subject).to receive(:link).with("self").and_return (expected = double)
438
+ expect(subject.url).to be expected
440
439
  end
441
440
  it "is nil when no link to self can be found" do
442
- subject.should_receive(:link).with "self"
443
- subject.url.should be_nil
441
+ expect(subject).to receive(:link).with "self"
442
+ expect(subject.url).to be_nil
444
443
  end
445
444
  end
446
445
  describe "#url_collection" do
447
446
  it "defaults to entry_point link which rel matches resource name" do
448
447
  Harpy.entry_point = double
449
- Harpy.entry_point.should_receive(:resource_url).with("harpy/spec/company").and_return (expected = double)
450
- subject.url_collection.should be expected
448
+ expect(Harpy.entry_point).to receive(:resource_url).with("harpy/spec/company").and_return (expected = double)
449
+ expect(subject.url_collection).to be expected
451
450
  end
452
451
  end
453
452
  describe "#id" do
454
453
  it "extracts last part from urn" do
455
454
  company = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
456
- company.id.should == "1"
455
+ expect(company.id).to eq("1")
457
456
  end
458
457
  it "works with alphanumeric ids too" do
459
458
  company = Harpy::Spec::Company.new "urn" => "urn:harpy:company:e{39,^"
460
- company.id.should == "e{39,^"
459
+ expect(company.id).to eq("e{39,^")
461
460
  end
462
461
  it "works with urns having more than 4 parts" do
463
462
  company = Harpy::Spec::Company.new "urn" => "urn:harpy:api:company:1"
464
- company.id.should == "1"
463
+ expect(company.id).to eq("1")
465
464
  end
466
465
  it "is nil without urn" do
467
- subject.id.should be_nil
466
+ expect(subject.id).to be_nil
468
467
  end
469
468
  it "is nil if urn is an empty string" do
470
469
  company = Harpy::Spec::Company.new "urn" => ""
471
- company.id.should be_nil
470
+ expect(company.id).to be_nil
472
471
  end
473
472
  it "never uses manually assigned id attribute" do
474
473
  company = Harpy::Spec::Company.new "id" => "1"
475
- company.id.should be_nil
474
+ expect(company.id).to be_nil
476
475
  end
477
476
  end
478
477
  describe "#persisted?" do
479
478
  it "defaults to false when no urn is defined" do
480
479
  company = Harpy::Spec::Company.new
481
- company.persisted?.should be_false
480
+ expect(company.persisted?).to be_falsey
482
481
  end
483
482
  it "is true when an urn is present" do
484
483
  company = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
485
- company.persisted?.should be_true
484
+ expect(company.persisted?).to be_truthy
486
485
  end
487
486
  it "is false when urn is an empty string" do
488
487
  company = Harpy::Spec::Company.new "urn" => ""
489
- company.persisted?.should be_false
488
+ expect(company.persisted?).to be_falsey
490
489
  end
491
490
  end
492
491
  describe "#inspect" do
493
492
  subject { Harpy::Spec::Company.new "firstname" => "Anthony" }
494
493
  it "shows class name, attributes, errors and persisted state" do
495
- subject.inspect.should == '<Harpy::Spec::Company @attrs:{"firstname"=>"Anthony"} @errors:[] persisted:false>'
494
+ expect(subject.inspect).to include("Harpy::Spec::Company", "firstname", "Anthony", "@errors:[] persisted:false>")
496
495
  end
497
496
  end
498
497
  describe "#has_key?(key)" do
499
498
  it "is true when attribute is present" do
500
- subject.has_key?("link").should be_true
499
+ expect(subject.has_key?("link")).to be_truthy
501
500
  end
502
501
  it "does accept symbols too" do
503
- subject.has_key?(:link).should be_true
502
+ expect(subject.has_key?(:link)).to be_truthy
504
503
  end
505
504
  it "is true when attribute is an empty string" do
506
505
  company = Harpy::Spec::Company.new "urn" => ""
507
- company.has_key?("urn").should be_true
506
+ expect(company.has_key?("urn")).to be_truthy
508
507
  end
509
508
  it "is false when attribute is not defined" do
510
- subject.has_key?("custom").should be_false
509
+ expect(subject.has_key?("custom")).to be_falsey
511
510
  end
512
511
  it "is false when key matches an existing method but not an attribute" do
513
- subject.has_key?(:url).should be_false
512
+ expect(subject.has_key?(:url)).to be_falsey
514
513
  end
515
514
  it "does not raise error when checking for an undefined attribute even when persisted" do
516
- subject.stub(:persisted?).and_return true
517
- subject.has_key?("custom").should be_false
515
+ allow(subject).to receive(:persisted?).and_return true
516
+ expect(subject.has_key?("custom")).to be_falsey
518
517
  end
519
518
  end
520
519
  end
521
520
  describe "#valid?" do
522
521
  it "has ActiveModel validations" do
523
522
  user = Harpy::Spec::User.new "lastname" => "Stark"
524
- user.should_not be_valid
525
- user.should have(1).error
526
- user.errors[:firstname].should =~ ["can't be blank"]
523
+ expect(user).not_to be_valid
524
+ expect(user.errors.size).to eq(1)
525
+ expect(user.errors[:firstname]).to match_array(["can't be blank"])
527
526
  end
528
- it "calls before_validation which prevents validation on false" do
527
+ it "calls before_validation which prevents validation on throw" do
529
528
  user = Harpy::Spec::User.new
530
- user.should_not be_valid
531
- user.should have(:no).error
529
+ expect(user).not_to be_valid
530
+ expect(user.errors.size).to eq(0)
532
531
  end
533
532
  end
534
533
  describe "#as_json" do
@@ -542,31 +541,31 @@ describe "class including Harpy::Resource" do
542
541
  end
543
542
 
544
543
  it "exclude link and urn from attributes" do
545
- subject.as_json.should == {"company_name" => "Stark Enterprises"}
544
+ expect(subject.as_json).to eq({"company_name" => "Stark Enterprises"})
546
545
  end
547
546
  it "does not remove link and urn from object attributes" do
548
547
  subject.as_json
549
- subject.urn.should == "urn:harpy:user:1"
550
- subject.url.should == url
548
+ expect(subject.urn).to eq("urn:harpy:user:1")
549
+ expect(subject.url).to eq(url)
551
550
  end
552
551
  end
553
552
  describe "#save" do
554
553
  subject{ Harpy::Spec::User.new "company_name" => "Stark Enterprises" }
555
554
  it "is false and does not call before_save callback if not valid" do
556
- subject.should_receive :valid?
557
- subject.save.should be_false
558
- subject.callbacks.should =~ []
555
+ expect(subject).to receive :valid?
556
+ expect(subject.save).to be_falsey
557
+ expect(subject.callbacks).to match_array([])
559
558
  end
560
559
  context "on create (valid, not persisted)" do
561
560
  let(:url) { "http://localhost/user" }
562
561
  let(:body) { '{"company_name":"Stark Enterprises"}' }
563
562
  before do
564
- subject.should_receive(:valid?).and_return true
565
- subject.should_receive(:url_collection).and_return url
563
+ expect(subject).to receive(:valid?).and_return true
564
+ expect(subject).to receive(:url_collection).and_return url
566
565
  end
567
566
  [200, 201, 302].each do |response_code|
568
567
  it "is true and merges response attributes on #{response_code}" do
569
- response = Typhoeus::Response.new :code => response_code, :body => <<-eos
568
+ response = httpx_response :code => response_code, :body => <<-eos
570
569
  {
571
570
  "firstname": "Anthony",
572
571
  "urn": "urn:harpy:user:1",
@@ -575,28 +574,28 @@ describe "class including Harpy::Resource" do
575
574
  ]
576
575
  }
577
576
  eos
578
- Harpy.client.should_receive(:post).with(url, :body => body).and_return response
579
- subject.save.should be_true
580
- subject.callbacks.should =~ [:save, :create]
581
- subject.firstname.should == "Anthony"
582
- subject.company_name.should == "Stark Enterprises"
583
- subject.urn.should == "urn:harpy:user:1"
577
+ expect(Harpy.client).to receive(:post).with(url, :body => body).and_return response
578
+ expect(subject.save).to be_truthy
579
+ expect(subject.callbacks).to match_array([:save, :create])
580
+ expect(subject.firstname).to eq("Anthony")
581
+ expect(subject.company_name).to eq("Stark Enterprises")
582
+ expect(subject.urn).to eq("urn:harpy:user:1")
584
583
  end
585
584
  end
586
585
  it "raises Harpy::InvalidResponseCode on 204" do
587
- response = Typhoeus::Response.new :code => 204
588
- Harpy.client.should_receive(:post).with(url, :body => body).and_return response
589
- lambda { subject.save }.should raise_error Harpy::InvalidResponseCode, "204"
590
- subject.callbacks.should =~ [:save, :create]
586
+ response = httpx_response :code => 204
587
+ expect(Harpy.client).to receive(:post).with(url, :body => body).and_return response
588
+ expect { subject.save }.to raise_error Harpy::InvalidResponseCode, "204"
589
+ expect(subject.callbacks).to match_array([:save, :create])
591
590
  end
592
591
  it "raises Harpy::Unauthorized on 401" do
593
- response = Typhoeus::Response.new :code => 401
594
- Harpy.client.should_receive(:post).with(url, :body => body).and_return response
595
- lambda { subject.save }.should raise_error Harpy::Unauthorized, "Server returned a 401 response code"
596
- subject.callbacks.should =~ [:save, :create]
592
+ response = httpx_response :code => 401
593
+ expect(Harpy.client).to receive(:post).with(url, :body => body).and_return response
594
+ expect { subject.save }.to raise_error Harpy::Unauthorized, "Server returned a 401 response code"
595
+ expect(subject.callbacks).to match_array([:save, :create])
597
596
  end
598
597
  it "is false and fills in errors on 422" do
599
- response = Typhoeus::Response.new :code => 422, :body => <<-eos
598
+ response = httpx_response :code => 422, :body => <<-eos
600
599
  {
601
600
  "firstname": "Anthony",
602
601
  "errors": {
@@ -604,28 +603,28 @@ describe "class including Harpy::Resource" do
604
603
  }
605
604
  }
606
605
  eos
607
- Harpy.client.should_receive(:post).with(url, :body => body).and_return response
608
- subject.save.should be_false
609
- subject.callbacks.should =~ [:save, :create]
610
- subject.should have(2).errors
611
- subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
612
- subject.firstname.should be_nil
613
- subject.company_name.should == "Stark Enterprises"
606
+ expect(Harpy.client).to receive(:post).with(url, :body => body).and_return response
607
+ expect(subject.save).to be_falsey
608
+ expect(subject.callbacks).to match_array([:save, :create])
609
+ expect(subject.errors.size).to eq(2)
610
+ expect(subject.errors[:lastname]).to match_array(["can't be blank", "must be unique"])
611
+ expect(subject.firstname).to be_nil
612
+ expect(subject.company_name).to eq("Stark Enterprises")
614
613
  end
615
614
  it "delegates other response codes to client" do
616
- response = Typhoeus::Response.new :code => 500
617
- Harpy.client.should_receive(:post).with(url, :body => body).and_return response
618
- Harpy.client.should_receive(:invalid_code).with(response)
615
+ response = httpx_response :code => 500
616
+ expect(Harpy.client).to receive(:post).with(url, :body => body).and_return response
617
+ expect(Harpy.client).to receive(:invalid_code).with(response)
619
618
  subject.save
620
- subject.callbacks.should =~ [:save, :create]
619
+ expect(subject.callbacks).to match_array([:save, :create])
621
620
  end
622
621
  end
623
622
  context "on update (valid, persisted but link to self is not present)" do
624
623
  it "raises Harpy::UrlRequired" do
625
- subject.should_receive(:valid?).and_return true
626
- subject.should_receive(:persisted?).and_return true
627
- lambda{ subject.save }.should raise_error Harpy::UrlRequired
628
- subject.callbacks.should =~ [:save, :update]
624
+ expect(subject).to receive(:valid?).and_return true
625
+ expect(subject).to receive(:persisted?).and_return true
626
+ expect{ subject.save }.to raise_error Harpy::UrlRequired
627
+ expect(subject.callbacks).to match_array([:save, :update])
629
628
  end
630
629
  end
631
630
  context "on update (valid, persisted and link to self is present)" do
@@ -639,11 +638,11 @@ describe "class including Harpy::Resource" do
639
638
  })
640
639
  end
641
640
  before do
642
- subject.should_receive(:valid?).and_return true
641
+ expect(subject).to receive(:valid?).and_return true
643
642
  end
644
643
  [200, 201, 302].each do |response_code|
645
644
  it "is true and merges response attributes on #{response_code}" do
646
- response = Typhoeus::Response.new :code => response_code, :body => <<-eos
645
+ response = httpx_response :code => response_code, :body => <<-eos
647
646
  {
648
647
  "firstname": "Anthony",
649
648
  "urn": "urn:harpy:user:1",
@@ -652,28 +651,28 @@ describe "class including Harpy::Resource" do
652
651
  ]
653
652
  }
654
653
  eos
655
- Harpy.client.should_receive(:put).with(url, :body => body).and_return response
656
- subject.save.should be_true
657
- subject.callbacks.should =~ [:save, :update]
658
- subject.firstname.should == "Anthony"
659
- subject.company_name.should == "Stark Enterprises"
654
+ expect(Harpy.client).to receive(:put).with(url, :body => body).and_return response
655
+ expect(subject.save).to be_truthy
656
+ expect(subject.callbacks).to match_array([:save, :update])
657
+ expect(subject.firstname).to eq("Anthony")
658
+ expect(subject.company_name).to eq("Stark Enterprises")
660
659
  end
661
660
  end
662
661
  it "is true but doesn't touch attributes on 204" do
663
- response = Typhoeus::Response.new :code => 204
664
- Harpy.client.should_receive(:put).with(url, :body => body).and_return response
665
- subject.save.should be_true
666
- subject.callbacks.should =~ [:save, :update]
667
- subject.company_name.should == "Stark Enterprises"
662
+ response = httpx_response :code => 204
663
+ expect(Harpy.client).to receive(:put).with(url, :body => body).and_return response
664
+ expect(subject.save).to be_truthy
665
+ expect(subject.callbacks).to match_array([:save, :update])
666
+ expect(subject.company_name).to eq("Stark Enterprises")
668
667
  end
669
668
  it "raises Harpy::Unauthorized on 401" do
670
- response = Typhoeus::Response.new :code => 401
671
- Harpy.client.should_receive(:put).with(url, :body => body).and_return response
672
- lambda { subject.save }.should raise_error Harpy::Unauthorized, "Server returned a 401 response code"
673
- subject.callbacks.should =~ [:save, :update]
669
+ response = httpx_response :code => 401
670
+ expect(Harpy.client).to receive(:put).with(url, :body => body).and_return response
671
+ expect { subject.save }.to raise_error Harpy::Unauthorized, "Server returned a 401 response code"
672
+ expect(subject.callbacks).to match_array([:save, :update])
674
673
  end
675
674
  it "is false and fills in errors on 422" do
676
- response = Typhoeus::Response.new :code => 422, :body => <<-eos
675
+ response = httpx_response :code => 422, :body => <<-eos
677
676
  {
678
677
  "firstname": "Anthony",
679
678
  "errors": {
@@ -681,20 +680,20 @@ describe "class including Harpy::Resource" do
681
680
  }
682
681
  }
683
682
  eos
684
- Harpy.client.should_receive(:put).with(url, :body => body).and_return response
685
- subject.save.should be_false
686
- subject.callbacks.should =~ [:save, :update]
687
- subject.should have(2).errors
688
- subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
689
- lambda { subject.firstname }.should raise_error NoMethodError
690
- subject.company_name.should == "Stark Enterprises"
683
+ expect(Harpy.client).to receive(:put).with(url, :body => body).and_return response
684
+ expect(subject.save).to be_falsey
685
+ expect(subject.callbacks).to match_array([:save, :update])
686
+ expect(subject.errors.size).to eq(2)
687
+ expect(subject.errors[:lastname]).to match_array(["can't be blank", "must be unique"])
688
+ expect { subject.firstname }.to raise_error NoMethodError
689
+ expect(subject.company_name).to eq("Stark Enterprises")
691
690
  end
692
691
  it "delegates other response codes to client" do
693
- response = Typhoeus::Response.new :code => 500
694
- Harpy.client.should_receive(:put).with(url, :body => body).and_return response
695
- Harpy.client.should_receive(:invalid_code).with(response)
692
+ response = httpx_response :code => 500
693
+ expect(Harpy.client).to receive(:put).with(url, :body => body).and_return response
694
+ expect(Harpy.client).to receive(:invalid_code).with(response)
696
695
  subject.save
697
- subject.callbacks.should =~ [:save, :update]
696
+ expect(subject.callbacks).to match_array([:save, :update])
698
697
  end
699
698
  end
700
699
  end
@@ -702,8 +701,8 @@ describe "class including Harpy::Resource" do
702
701
  subject{ Harpy::Spec::User.new "company_name" => "Stark Enterprises" }
703
702
  context "when link to self is missing" do
704
703
  it "raises Harpy::UrlRequired" do
705
- lambda{ subject.destroy }.should raise_error Harpy::UrlRequired
706
- subject.callbacks.should =~ []
704
+ expect{ subject.destroy }.to raise_error Harpy::UrlRequired
705
+ expect(subject.callbacks).to match_array([])
707
706
  end
708
707
  end
709
708
  context "when link to self is present" do
@@ -717,7 +716,7 @@ describe "class including Harpy::Resource" do
717
716
  end
718
717
  [200, 201, 302].each do |response_code|
719
718
  it "is true and merges response attributes on #{response_code}" do
720
- response = Typhoeus::Response.new :code => response_code, :body => <<-eos
719
+ response = httpx_response :code => response_code, :body => <<-eos
721
720
  {
722
721
  "firstname": "Anthony",
723
722
  "urn": "urn:harpy:user:1",
@@ -726,28 +725,28 @@ describe "class including Harpy::Resource" do
726
725
  ]
727
726
  }
728
727
  eos
729
- Harpy.client.should_receive(:delete).with(url).and_return response
730
- subject.destroy.should be_true
731
- subject.callbacks.should =~ [:destroy]
732
- subject.firstname.should == "Anthony"
733
- subject.company_name.should == "Stark Enterprises"
728
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
729
+ expect(subject.destroy).to be_truthy
730
+ expect(subject.callbacks).to match_array([:destroy])
731
+ expect(subject.firstname).to eq("Anthony")
732
+ expect(subject.company_name).to eq("Stark Enterprises")
734
733
  end
735
734
  end
736
735
  it "is true but doesn't touch attributes on 204" do
737
- response = Typhoeus::Response.new :code => 204
738
- Harpy.client.should_receive(:delete).with(url).and_return response
739
- subject.destroy.should be_true
740
- subject.callbacks.should =~ [:destroy]
741
- subject.company_name.should == "Stark Enterprises"
736
+ response = httpx_response :code => 204
737
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
738
+ expect(subject.destroy).to be_truthy
739
+ expect(subject.callbacks).to match_array([:destroy])
740
+ expect(subject.company_name).to eq("Stark Enterprises")
742
741
  end
743
742
  it "raises Harpy::Unauthorized on 401" do
744
- response = Typhoeus::Response.new :code => 401
745
- Harpy.client.should_receive(:delete).with(url).and_return response
746
- lambda { subject.destroy }.should raise_error Harpy::Unauthorized, "Server returned a 401 response code"
747
- subject.callbacks.should =~ [:destroy]
743
+ response = httpx_response :code => 401
744
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
745
+ expect { subject.destroy }.to raise_error Harpy::Unauthorized, "Server returned a 401 response code"
746
+ expect(subject.callbacks).to match_array([:destroy])
748
747
  end
749
748
  it "is false and fills in errors on 422" do
750
- response = Typhoeus::Response.new :code => 422, :body => <<-eos
749
+ response = httpx_response :code => 422, :body => <<-eos
751
750
  {
752
751
  "firstname": "Anthony",
753
752
  "errors": {
@@ -755,20 +754,20 @@ describe "class including Harpy::Resource" do
755
754
  }
756
755
  }
757
756
  eos
758
- Harpy.client.should_receive(:delete).with(url).and_return response
759
- subject.destroy.should be_false
760
- subject.callbacks.should =~ [:destroy]
761
- subject.should have(2).errors
762
- subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
763
- lambda { subject.firstname }.should raise_error NoMethodError
764
- subject.company_name.should == "Stark Enterprises"
757
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
758
+ expect(subject.destroy).to be_falsey
759
+ expect(subject.callbacks).to match_array([:destroy])
760
+ expect(subject.errors.size).to eq(2)
761
+ expect(subject.errors[:lastname]).to match_array(["can't be blank", "must be unique"])
762
+ expect { subject.firstname }.to raise_error NoMethodError
763
+ expect(subject.company_name).to eq("Stark Enterprises")
765
764
  end
766
765
  it "delegates other response codes to client" do
767
- response = Typhoeus::Response.new :code => 500
768
- Harpy.client.should_receive(:delete).with(url).and_return response
769
- Harpy.client.should_receive(:invalid_code).with(response)
766
+ response = httpx_response :code => 500
767
+ expect(Harpy.client).to receive(:delete).with(url).and_return response
768
+ expect(Harpy.client).to receive(:invalid_code).with(response)
770
769
  subject.destroy
771
- subject.callbacks.should =~ [:destroy]
770
+ expect(subject.callbacks).to match_array([:destroy])
772
771
  end
773
772
  end
774
773
  end
@@ -776,22 +775,22 @@ describe "class including Harpy::Resource" do
776
775
  it "is equal to itself even without urn" do
777
776
  company1 = Harpy::Spec::Company.new
778
777
  company2 = company1
779
- company1.should == company2
778
+ expect(company1).to eq(company2)
780
779
  end
781
780
  it "two instances without urn are not equal" do
782
781
  company1 = Harpy::Spec::Company.new
783
782
  company2 = Harpy::Spec::Company.new
784
- company1.should_not == company2
783
+ expect(company1).not_to eq(company2)
785
784
  end
786
785
  it "two instances of the same class with the same urn are equal" do
787
786
  company1 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
788
787
  company2 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
789
- company1.should == company2
788
+ expect(company1).to eq(company2)
790
789
  end
791
790
  it "two instances of the same class with different urns are not equal" do
792
791
  company1 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
793
792
  company2 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:2"
794
- company1.should_not == company2
793
+ expect(company1).not_to eq(company2)
795
794
  end
796
795
  end
797
796
  end