active_remote 2.1.1 → 2.2.0

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.
@@ -17,7 +17,7 @@ describe ActiveRemote::DSL do
17
17
  Tag.attr_publishable :guid
18
18
  Tag.attr_publishable :name
19
19
 
20
- Tag.publishable_attributes.should =~ [ :guid, :name ]
20
+ expect(Tag.publishable_attributes).to match_array([ :guid, :name ])
21
21
  end
22
22
  end
23
23
 
@@ -25,7 +25,7 @@ describe ActiveRemote::DSL do
25
25
  context "when given a value" do
26
26
  it "sets @namespace to the value" do
27
27
  Tag.namespace :foo
28
- Tag.namespace.should eq :foo
28
+ expect(Tag.namespace).to eq :foo
29
29
  end
30
30
  end
31
31
  end
@@ -35,14 +35,14 @@ describe ActiveRemote::DSL do
35
35
  it "determines the service class" do
36
36
  Tag.namespace :another
37
37
 
38
- Tag.service_class.should eq Another::TagService
38
+ expect(Tag.service_class).to eq Another::TagService
39
39
  end
40
40
  end
41
41
 
42
42
  context "when given a value" do
43
43
  it "sets @service_class to the value" do
44
44
  Tag.service_class Generic::Remote::TagService
45
- Tag.service_class.should eq Generic::Remote::TagService
45
+ expect(Tag.service_class).to eq Generic::Remote::TagService
46
46
  end
47
47
  end
48
48
  end
@@ -50,14 +50,14 @@ describe ActiveRemote::DSL do
50
50
  describe ".service_name" do
51
51
  context "when nil" do
52
52
  it "determines the service name" do
53
- Tag.service_name.should eq :tag_service
53
+ expect(Tag.service_name).to eq :tag_service
54
54
  end
55
55
  end
56
56
 
57
57
  context "when given a value" do
58
58
  it "sets @service_name to the value" do
59
59
  Tag.service_name :foo
60
- Tag.service_name.should eq :foo
60
+ expect(Tag.service_name).to eq :foo
61
61
  end
62
62
  end
63
63
  end
@@ -6,38 +6,38 @@ describe ::ActiveRemote::Integration do
6
6
 
7
7
  context "#to_param" do
8
8
  # API
9
- specify { subject.should respond_to(:to_param) }
9
+ specify { expect(subject).to respond_to(:to_param) }
10
10
 
11
11
  it "returns the guid if the guid is present (by default)" do
12
- subject.to_param.should eq(guid)
12
+ expect(subject.to_param).to eq(guid)
13
13
  end
14
14
  end
15
15
 
16
16
  context "#cache_key" do
17
17
  # API
18
- specify { subject.should respond_to(:cache_key) }
18
+ specify { expect(subject).to respond_to(:cache_key) }
19
19
 
20
20
  it "sets 'new' as the identifier when the record has not been persisted" do
21
- subject.should_receive(:new_record?).and_return(true)
22
- subject.cache_key.should match(/tag\/new/)
21
+ expect(subject).to receive(:new_record?).and_return(true)
22
+ expect(subject.cache_key).to match(/tag\/new/)
23
23
  end
24
24
 
25
25
  it "sets the cache_key to the class/guid as a default" do
26
- subject.should_receive(:new_record?).and_return(false)
27
- subject.cache_key.should eq("tag/#{guid}")
26
+ expect(subject).to receive(:new_record?).and_return(false)
27
+ expect(subject.cache_key).to eq("tag/#{guid}")
28
28
  end
29
29
 
30
30
  it "adds the 'updated_at' attribute to the cache_key if updated_at is present" do
31
31
  ::ActiveRemote.config.default_cache_key_updated_at = true
32
32
  twenty_o_one_one = subject[:updated_at] = DateTime.new(2001, 01, 01)
33
- subject.should_receive(:new_record?).and_return(false)
34
- subject.cache_key.should eq("tag/#{guid}-#{twenty_o_one_one.to_s(:number)}")
33
+ expect(subject).to receive(:new_record?).and_return(false)
34
+ expect(subject.cache_key).to eq("tag/#{guid}-#{twenty_o_one_one.to_s(:number)}")
35
35
  subject[:updated_at] = nil
36
36
  ::ActiveRemote.config.default_cache_key_updated_at = false
37
37
  end
38
38
 
39
39
  it "defaults the cache updated_at to false" do
40
- ::ActiveRemote.config.default_cache_key_updated_at?.should be_false
40
+ expect(::ActiveRemote.config.default_cache_key_updated_at?).to be_falsey
41
41
  end
42
42
  end
43
43
  end
@@ -7,36 +7,36 @@ describe ActiveRemote::Persistence do
7
7
 
8
8
  before {
9
9
  rpc.better_stub(:execute).and_return(HashWithIndifferentAccess.new)
10
- HashWithIndifferentAccess.any_instance.stub(:errors).and_return([])
10
+ allow_any_instance_of(HashWithIndifferentAccess).to receive(:errors).and_return([])
11
11
  Tag.better_stub(:rpc).and_return(rpc)
12
12
  }
13
- after { Tag.unstub(:rpc) }
13
+ after { allow(Tag).to receive(:rpc).and_call_original }
14
14
 
15
15
  describe ".create" do
16
16
  it "runs create callbacks" do
17
- Tag.any_instance.should_receive(:after_create_callback)
17
+ expect_any_instance_of(Tag).to receive(:after_create_callback)
18
18
  Tag.create(:name => 'foo')
19
19
  end
20
20
 
21
21
  it "initializes and saves a new record" do
22
- Tag.any_instance.should_receive(:save)
22
+ expect_any_instance_of(Tag).to receive(:save)
23
23
  Tag.create(:name => 'foo')
24
24
  end
25
25
 
26
26
  it "returns a new record" do
27
27
  value = Tag.create(:name => 'foo')
28
- value.should be_a(Tag)
28
+ expect(value).to be_a(Tag)
29
29
  end
30
30
  end
31
31
 
32
32
  describe ".create!" do
33
33
  it "initializes and saves a new record" do
34
- Tag.any_instance.should_receive(:save!)
34
+ expect_any_instance_of(Tag).to receive(:save!)
35
35
  Tag.create!(:name => 'foo')
36
36
  end
37
37
 
38
38
  context "when the record has errors" do
39
- before { Tag.any_instance.stub(:save!).and_raise(ActiveRemote::ActiveRemoteError) }
39
+ before { allow_any_instance_of(Tag).to receive(:save!).and_raise(ActiveRemote::ActiveRemoteError) }
40
40
 
41
41
  it "raises an exception" do
42
42
  expect { Tag.create!(:name => 'foo') }.to raise_error(ActiveRemote::ActiveRemoteError)
@@ -46,14 +46,14 @@ describe ActiveRemote::Persistence do
46
46
 
47
47
  describe "#delete" do
48
48
  it "deletes a remote record" do
49
- rpc.should_receive(:execute).with(:delete, subject.scope_key_hash)
49
+ expect(rpc).to receive(:execute).with(:delete, subject.scope_key_hash)
50
50
  subject.delete
51
51
  end
52
52
 
53
53
  context "when the record doesn't have errors" do
54
54
  it "freezes the record" do
55
55
  subject.delete
56
- subject.frozen?.should be_true
56
+ expect(subject.frozen?).to be_truthy
57
57
  end
58
58
  end
59
59
 
@@ -65,18 +65,18 @@ describe ActiveRemote::Persistence do
65
65
 
66
66
  it "adds the errors to the record" do
67
67
  subject.delete
68
- subject.has_errors?.should be_true
68
+ expect(subject.has_errors?).to be_truthy
69
69
  end
70
70
 
71
71
  it "returns false" do
72
- subject.delete.should be_false
72
+ expect(subject.delete).to be_falsey
73
73
  end
74
74
  end
75
75
  end
76
76
 
77
77
  describe "#delete!" do
78
78
  it "deletes a remote record" do
79
- rpc.should_receive(:execute).with(:delete, subject.scope_key_hash)
79
+ expect(rpc).to receive(:execute).with(:delete, subject.scope_key_hash)
80
80
  subject.delete!
81
81
  end
82
82
 
@@ -94,14 +94,14 @@ describe ActiveRemote::Persistence do
94
94
 
95
95
  describe "#destroy" do
96
96
  it "destroys a remote record" do
97
- rpc.should_receive(:execute).with(:destroy, subject.scope_key_hash)
97
+ expect(rpc).to receive(:execute).with(:destroy, subject.scope_key_hash)
98
98
  subject.destroy
99
99
  end
100
100
 
101
101
  context "when the record doesn't have errors" do
102
102
  it "freezes the record" do
103
103
  subject.destroy
104
- subject.frozen?.should be_true
104
+ expect(subject.frozen?).to be_truthy
105
105
  end
106
106
  end
107
107
 
@@ -113,18 +113,18 @@ describe ActiveRemote::Persistence do
113
113
 
114
114
  it "adds the errors to the record" do
115
115
  subject.destroy
116
- subject.has_errors?.should be_true
116
+ expect(subject.has_errors?).to be_truthy
117
117
  end
118
118
 
119
119
  it "returns false" do
120
- subject.destroy.should be_false
120
+ expect(subject.destroy).to be_falsey
121
121
  end
122
122
  end
123
123
  end
124
124
 
125
125
  describe "#destroy!" do
126
126
  it "destroys a remote record" do
127
- rpc.should_receive(:execute).with(:destroy, subject.scope_key_hash)
127
+ expect(rpc).to receive(:execute).with(:destroy, subject.scope_key_hash)
128
128
  subject.destroy!
129
129
  end
130
130
 
@@ -144,8 +144,8 @@ describe ActiveRemote::Persistence do
144
144
  context "when the record is created through instantiate with options[:readonly]" do
145
145
  subject { Tag.instantiate({:guid => 'foo'}, :readonly => true) }
146
146
 
147
- its(:new_record?) { should be_false }
148
- its(:readonly?) { should be_true }
147
+ its(:new_record?) { should be_falsey }
148
+ its(:readonly?) { should be_truthy }
149
149
  end
150
150
  end
151
151
 
@@ -153,13 +153,13 @@ describe ActiveRemote::Persistence do
153
153
  context "when errors are not present" do
154
154
  before { subject.errors.clear }
155
155
 
156
- its(:has_errors?) { should be_false }
156
+ its(:has_errors?) { should be_falsey }
157
157
  end
158
158
 
159
159
  context "when errors are present" do
160
160
  before { subject.errors[:base] << "Boom!" }
161
161
 
162
- its(:has_errors?) { should be_true }
162
+ its(:has_errors?) { should be_truthy }
163
163
  end
164
164
  end
165
165
 
@@ -167,19 +167,19 @@ describe ActiveRemote::Persistence do
167
167
  context "when the record is created through instantiate" do
168
168
  subject { Tag.instantiate(:guid => 'foo') }
169
169
 
170
- its(:new_record?) { should be_false }
170
+ its(:new_record?) { should be_falsey }
171
171
  end
172
172
 
173
173
  context "when the record is persisted" do
174
174
  subject { Tag.allocate.instantiate(:guid => 'foo') }
175
175
 
176
- its(:new_record?) { should be_false }
176
+ its(:new_record?) { should be_falsey }
177
177
  end
178
178
 
179
179
  context "when the record is not persisted" do
180
180
  subject { Tag.new }
181
181
 
182
- its(:new_record?) { should be_true }
182
+ its(:new_record?) { should be_truthy }
183
183
  end
184
184
  end
185
185
 
@@ -187,19 +187,19 @@ describe ActiveRemote::Persistence do
187
187
  context "when the record is persisted" do
188
188
  subject { Tag.allocate.instantiate(:guid => 'foo') }
189
189
 
190
- its(:persisted?) { should be_true }
190
+ its(:persisted?) { should be_truthy }
191
191
  end
192
192
 
193
193
  context "when the record is not persisted" do
194
194
  subject { Tag.new }
195
195
 
196
- its(:persisted?) { should be_false }
196
+ its(:persisted?) { should be_falsey }
197
197
  end
198
198
  end
199
199
 
200
200
  describe "#save" do
201
201
  it "runs save callbacks" do
202
- subject.should_receive(:run_callbacks).with(:save)
202
+ expect(subject).to receive(:run_callbacks).with(:save)
203
203
  subject.save
204
204
  end
205
205
 
@@ -208,7 +208,7 @@ describe ActiveRemote::Persistence do
208
208
 
209
209
  it "creates the record" do
210
210
  expected_attributes = subject.attributes.reject { |key, value| key == "guid" }
211
- rpc.should_receive(:execute).with(:create, expected_attributes)
211
+ expect(rpc).to receive(:execute).with(:create, expected_attributes)
212
212
  subject.save
213
213
  end
214
214
  end
@@ -219,7 +219,7 @@ describe ActiveRemote::Persistence do
219
219
  subject { Tag.allocate.instantiate(attributes) }
220
220
 
221
221
  it "updates the record" do
222
- rpc.should_receive(:execute).with(:update, attributes)
222
+ expect(rpc).to receive(:execute).with(:update, attributes)
223
223
  subject.save
224
224
  end
225
225
  end
@@ -227,14 +227,14 @@ describe ActiveRemote::Persistence do
227
227
  context "when the record is saved" do
228
228
  it "returns true" do
229
229
  subject.better_stub(:has_errors?) { false }
230
- subject.save.should be_true
230
+ expect(subject.save).to be_truthy
231
231
  end
232
232
  end
233
233
 
234
234
  context "when the record is not saved" do
235
235
  it "returns false" do
236
236
  subject.better_stub(:has_errors?) { true }
237
- subject.save.should be_false
237
+ expect(subject.save).to be_falsey
238
238
  end
239
239
  end
240
240
 
@@ -242,27 +242,27 @@ describe ActiveRemote::Persistence do
242
242
  before { subject.errors[:base] << "Boom!" }
243
243
 
244
244
  it "clears the errors before the save" do
245
- subject.errors.should_not be_empty
246
- subject.save.should be_true
247
- subject.errors.should be_empty
245
+ expect(subject.errors).not_to be_empty
246
+ expect(subject.save).to be_truthy
247
+ expect(subject.errors).to be_empty
248
248
  end
249
249
  end
250
250
  end
251
251
 
252
252
  describe "#save!" do
253
- before { subject.stub(:execute) }
254
- after { subject.unstub(:execute) }
253
+ before { allow(subject).to receive(:execute) }
254
+ after { allow(subject).to receive(:execute).and_call_original }
255
255
 
256
256
  context "when the record is saved" do
257
257
  it "returns true" do
258
- subject.stub(:save).and_return(true)
259
- subject.save!.should be_true
258
+ allow(subject).to receive(:save).and_return(true)
259
+ expect(subject.save!).to be_truthy
260
260
  end
261
261
  end
262
262
 
263
263
  context "when the record is not saved" do
264
264
  it "raises an exception" do
265
- subject.stub(:save).and_return(false)
265
+ allow(subject).to receive(:save).and_return(false)
266
266
  expect { subject.save! }.to raise_error(ActiveRemote::RemoteRecordNotSaved)
267
267
  end
268
268
  end
@@ -272,13 +272,13 @@ describe ActiveRemote::Persistence do
272
272
  context "when errors are present" do
273
273
  before { subject.errors[:base] << "Boom!" }
274
274
 
275
- its(:success?) { should be_false }
275
+ its(:success?) { should be_falsey }
276
276
  end
277
277
 
278
278
  context "when errors are not present" do
279
279
  before { subject.errors.clear }
280
280
 
281
- its(:success?) { should be_true }
281
+ its(:success?) { should be_truthy }
282
282
  end
283
283
  end
284
284
 
@@ -286,29 +286,29 @@ describe ActiveRemote::Persistence do
286
286
  let(:attributes) { HashWithIndifferentAccess.new(:name => 'bar') }
287
287
  let(:tag) { Tag.allocate.instantiate({:guid => "123"}) }
288
288
 
289
- before { Tag.rpc.stub(:execute).and_return(HashWithIndifferentAccess.new) }
290
- after { Tag.rpc.unstub(:execute) }
289
+ before { allow(Tag.rpc).to receive(:execute).and_return(HashWithIndifferentAccess.new) }
290
+ after { allow(Tag.rpc).to receive(:execute).and_call_original }
291
291
 
292
292
  it "runs update callbacks" do
293
- tag.should_receive(:after_update_callback)
293
+ expect(tag).to receive(:after_update_callback)
294
294
  tag.update_attributes({})
295
295
  end
296
296
 
297
297
  it "updates a remote record" do
298
- Tag.rpc.should_receive(:execute).with(:update, tag.scope_key_hash)
298
+ expect(Tag.rpc).to receive(:execute).with(:update, tag.scope_key_hash)
299
299
  tag.update_attributes({})
300
300
  end
301
301
 
302
- before { subject.stub(:save) }
303
- after { subject.unstub(:save) }
302
+ before { allow(subject).to receive(:save) }
303
+ after { allow(subject).to receive(:save).and_call_original }
304
304
 
305
305
  it "assigns new attributes" do
306
- subject.should_receive(:assign_attributes).with(attributes)
306
+ expect(subject).to receive(:assign_attributes).with(attributes)
307
307
  subject.update_attributes(attributes)
308
308
  end
309
309
 
310
310
  it "saves the record" do
311
- subject.should_receive(:save)
311
+ expect(subject).to receive(:save)
312
312
  subject.update_attributes(attributes)
313
313
  end
314
314
  end
@@ -316,16 +316,16 @@ describe ActiveRemote::Persistence do
316
316
  describe "#update_attributes!" do
317
317
  let(:attributes) { HashWithIndifferentAccess.new(:name => 'bar') }
318
318
 
319
- before { subject.stub(:save!) }
320
- after { subject.unstub(:save!) }
319
+ before { allow(subject).to receive(:save!) }
320
+ after { allow(subject).to receive(:save!).and_call_original }
321
321
 
322
322
  it "assigns new attributes" do
323
- subject.should_receive(:assign_attributes).with(attributes)
323
+ expect(subject).to receive(:assign_attributes).with(attributes)
324
324
  subject.update_attributes!(attributes)
325
325
  end
326
326
 
327
327
  it "saves! the record" do
328
- subject.should_receive(:save!)
328
+ expect(subject).to receive(:save!)
329
329
  subject.update_attributes!(attributes)
330
330
  end
331
331
  end
@@ -7,14 +7,14 @@ describe ActiveRemote::PrimaryKey do
7
7
 
8
8
  describe ".default_primary_key" do
9
9
  it 'returns array of :guid' do
10
- Tag.default_primary_key.should eq(:guid)
10
+ expect(Tag.default_primary_key).to eq(:guid)
11
11
  end
12
12
  end
13
13
 
14
14
  describe "primary_key" do
15
15
  context "when no arguments are passed" do
16
16
  it "returns default primary key" do
17
- Tag.primary_key.should eq(:guid)
17
+ expect(Tag.primary_key).to eq(:guid)
18
18
  end
19
19
  end
20
20
 
@@ -22,14 +22,14 @@ describe ActiveRemote::PrimaryKey do
22
22
  let(:specified_primary_key) { :name }
23
23
 
24
24
  it "returns the given primary key" do
25
- Tag.primary_key(specified_primary_key).should eq(specified_primary_key)
25
+ expect(Tag.primary_key(specified_primary_key)).to eq(specified_primary_key)
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
30
  describe "#primary_key" do
31
31
  it "returns the primary key for the class" do
32
- Tag.new.primary_key.should eq Tag.primary_key
32
+ expect(Tag.new.primary_key).to eq Tag.primary_key
33
33
  end
34
34
  end
35
35
  end