active_remote 3.3.3 → 5.0.0.pre
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 +4 -4
- data/.rubocop.yml +28 -0
- data/CHANGES.md +13 -0
- data/Gemfile +1 -1
- data/Rakefile +7 -3
- data/active_remote.gemspec +8 -6
- data/lib/active_remote.rb +9 -8
- data/lib/active_remote/association.rb +12 -14
- data/lib/active_remote/attribute_definition.rb +14 -12
- data/lib/active_remote/attributes.rb +6 -6
- data/lib/active_remote/base.rb +20 -27
- data/lib/active_remote/config.rb +1 -1
- data/lib/active_remote/dirty.rb +3 -3
- data/lib/active_remote/dsl.rb +3 -4
- data/lib/active_remote/errors.rb +1 -11
- data/lib/active_remote/persistence.rb +11 -12
- data/lib/active_remote/primary_key.rb +0 -1
- data/lib/active_remote/query_attributes.rb +13 -13
- data/lib/active_remote/rpc.rb +8 -14
- data/lib/active_remote/rpc_adapters/protobuf_adapter.rb +18 -17
- data/lib/active_remote/scope_keys.rb +1 -2
- data/lib/active_remote/search.rb +8 -6
- data/lib/active_remote/serializers/protobuf.rb +15 -25
- data/lib/active_remote/validations.rb +1 -1
- data/lib/active_remote/version.rb +1 -1
- data/spec/lib/active_remote/association_spec.rb +23 -23
- data/spec/lib/active_remote/attributes_spec.rb +49 -3
- data/spec/lib/active_remote/base_spec.rb +1 -1
- data/spec/lib/active_remote/dirty_spec.rb +12 -12
- data/spec/lib/active_remote/dsl_spec.rb +4 -4
- data/spec/lib/active_remote/integration_spec.rb +2 -2
- data/spec/lib/active_remote/persistence_spec.rb +26 -33
- data/spec/lib/active_remote/primary_key_spec.rb +3 -3
- data/spec/lib/active_remote/query_attribute_spec.rb +0 -120
- data/spec/lib/active_remote/rpc_adapters/protobuf_adapter_spec.rb +1 -1
- data/spec/lib/active_remote/rpc_spec.rb +1 -1
- data/spec/lib/active_remote/scope_keys_spec.rb +7 -7
- data/spec/lib/active_remote/search_spec.rb +8 -8
- data/spec/lib/active_remote/serialization_spec.rb +4 -4
- data/spec/lib/active_remote/serializers/protobuf_spec.rb +23 -23
- data/spec/lib/active_remote/validations_spec.rb +17 -17
- data/spec/spec_helper.rb +9 -9
- data/spec/support/helpers.rb +6 -6
- data/spec/support/models.rb +8 -8
- data/spec/support/models/author.rb +1 -1
- data/spec/support/models/category.rb +1 -2
- data/spec/support/models/default_author.rb +1 -1
- data/spec/support/models/post.rb +4 -4
- data/spec/support/models/tag.rb +1 -1
- data/spec/support/models/typecasted_author.rb +4 -5
- data/spec/support/protobuf.rb +5 -5
- metadata +24 -26
- data/lib/active_remote/attribute_assignment.rb +0 -53
- data/lib/active_remote/type.rb +0 -36
- data/lib/active_remote/type/registry.rb +0 -45
- data/lib/active_remote/typecasting.rb +0 -51
- data/lib/active_remote/typecasting/big_decimal_typecaster.rb +0 -21
- data/lib/active_remote/typecasting/boolean.rb +0 -7
- data/lib/active_remote/typecasting/boolean_typecaster.rb +0 -18
- data/lib/active_remote/typecasting/date_time_typecaster.rb +0 -10
- data/lib/active_remote/typecasting/date_typecaster.rb +0 -10
- data/lib/active_remote/typecasting/float_typecaster.rb +0 -9
- data/lib/active_remote/typecasting/integer_typecaster.rb +0 -10
- data/lib/active_remote/typecasting/object_typecaster.rb +0 -9
- data/lib/active_remote/typecasting/string_typecaster.rb +0 -9
- data/spec/lib/active_remote/errors_spec.rb +0 -31
- data/spec/lib/active_remote/typecasting_spec.rb +0 -53
@@ -15,6 +15,52 @@ describe ::ActiveRemote::Attributes do
|
|
15
15
|
end
|
16
16
|
subject { ::Author.new }
|
17
17
|
|
18
|
+
describe "type casting" do
|
19
|
+
let(:test_class) { ::TypecastedAuthor }
|
20
|
+
|
21
|
+
describe "boolean" do
|
22
|
+
it "casts to boolean" do
|
23
|
+
record = test_class.new(:writes_fiction => "f")
|
24
|
+
expect(record.writes_fiction).to eq(false)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "datetime" do
|
29
|
+
it "casts to datetime" do
|
30
|
+
record = test_class.new(:birthday => "2016-01-01")
|
31
|
+
expect(record.birthday).to eq(DateTime.parse("2016-01-01"))
|
32
|
+
end
|
33
|
+
|
34
|
+
context "invalid date" do
|
35
|
+
it "sets attribute to nil" do
|
36
|
+
record = test_class.new(:birthday => "23451234")
|
37
|
+
expect(record.birthday).to be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "float" do
|
43
|
+
it "casts to float" do
|
44
|
+
record = test_class.new(:net_sales => "2000.20")
|
45
|
+
expect(record.net_sales).to eq(2000.2)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "integer" do
|
50
|
+
it "casts to integer" do
|
51
|
+
record = test_class.new(:age => "40")
|
52
|
+
expect(record.age).to eq(40)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "string" do
|
57
|
+
it "casts to string" do
|
58
|
+
record = test_class.new(:guid => 1000)
|
59
|
+
expect(record.guid).to eq("1000")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
18
64
|
describe ".attribute" do
|
19
65
|
context "a dangerous attribute" do
|
20
66
|
it "raises an error" do
|
@@ -98,7 +144,7 @@ describe ::ActiveRemote::Attributes do
|
|
98
144
|
end
|
99
145
|
|
100
146
|
it "returns a new Hash " do
|
101
|
-
subject.attributes
|
147
|
+
subject.attributes["foobar"] = "foobar"
|
102
148
|
expect(subject.attributes).to_not include("foobar" => "foobar")
|
103
149
|
end
|
104
150
|
|
@@ -112,11 +158,11 @@ describe ::ActiveRemote::Attributes do
|
|
112
158
|
before { subject.name = "test" }
|
113
159
|
|
114
160
|
it "includes the class name and all attribute values in alphabetical order by attribute name" do
|
115
|
-
expect(subject.inspect).to eq(%
|
161
|
+
expect(subject.inspect).to eq(%(#<Author category_guid: nil, chief_editor_guid: nil, editor_guid: nil, guid: nil, name: "test", user_guid: nil>))
|
116
162
|
end
|
117
163
|
|
118
164
|
it "doesn't format the inspection string for attributes if the model does not have any" do
|
119
|
-
expect(::NoAttributes.new.inspect).to eq(%
|
165
|
+
expect(::NoAttributes.new.inspect).to eq(%(#<NoAttributes>))
|
120
166
|
end
|
121
167
|
end
|
122
168
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ActiveRemote::Dirty do
|
4
4
|
context "when writing attributes through the setter" do
|
5
|
-
subject { Post.new(:name =>
|
5
|
+
subject { Post.new(:name => "foo") }
|
6
6
|
|
7
7
|
before {
|
8
8
|
subject.previous_changes.try(:clear)
|
@@ -10,20 +10,20 @@ describe ActiveRemote::Dirty do
|
|
10
10
|
}
|
11
11
|
|
12
12
|
context "when the value changes" do
|
13
|
-
before { subject.name =
|
13
|
+
before { subject.name = "bar" }
|
14
14
|
|
15
15
|
its(:name_changed?) { should be_truthy }
|
16
16
|
end
|
17
17
|
|
18
18
|
context "when the value doesn't change" do
|
19
|
-
before { subject.name =
|
19
|
+
before { subject.name = "foo" }
|
20
20
|
|
21
21
|
its(:name_changed?) { should be_falsey }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
context "when writing attributes directly" do
|
26
|
-
subject { Post.new(:name =>
|
26
|
+
subject { Post.new(:name => "foo") }
|
27
27
|
|
28
28
|
before {
|
29
29
|
subject.previous_changes.try(:clear)
|
@@ -31,23 +31,23 @@ describe ActiveRemote::Dirty do
|
|
31
31
|
}
|
32
32
|
|
33
33
|
context "when the value changes" do
|
34
|
-
before { subject[:name] =
|
34
|
+
before { subject[:name] = "bar" }
|
35
35
|
|
36
36
|
its(:name_changed?) { should be_truthy }
|
37
37
|
end
|
38
38
|
|
39
39
|
context "when the value doesn't change" do
|
40
|
-
before { subject[:name] =
|
40
|
+
before { subject[:name] = "foo" }
|
41
41
|
|
42
42
|
its(:name_changed?) { should be_falsey }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#reload" do
|
47
|
-
subject { Post.new(:name =>
|
47
|
+
subject { Post.new(:name => "foo") }
|
48
48
|
|
49
49
|
before {
|
50
|
-
allow(Post).to receive(:find).and_return(Post.new(:name =>
|
50
|
+
allow(Post).to receive(:find).and_return(Post.new(:name => "foo"))
|
51
51
|
subject.reload
|
52
52
|
}
|
53
53
|
|
@@ -57,7 +57,7 @@ describe ActiveRemote::Dirty do
|
|
57
57
|
describe "#save" do
|
58
58
|
let!(:changes) { subject.changes }
|
59
59
|
|
60
|
-
subject { Post.new(:name =>
|
60
|
+
subject { Post.new(:name => "foo") }
|
61
61
|
|
62
62
|
before {
|
63
63
|
allow(subject).to receive(:create_or_update).and_return(true)
|
@@ -71,7 +71,7 @@ describe ActiveRemote::Dirty do
|
|
71
71
|
describe "#save!" do
|
72
72
|
let!(:changes) { subject.changes }
|
73
73
|
|
74
|
-
subject { Post.new(:name =>
|
74
|
+
subject { Post.new(:name => "foo") }
|
75
75
|
|
76
76
|
before {
|
77
77
|
allow(subject).to receive(:save).and_return(true)
|
@@ -84,7 +84,7 @@ describe ActiveRemote::Dirty do
|
|
84
84
|
|
85
85
|
describe "#instantiate" do
|
86
86
|
let(:post) { Post.new }
|
87
|
-
let(:record) { ::Generic::Remote::Post.new(:name =>
|
87
|
+
let(:record) { ::Generic::Remote::Post.new(:name => "foo") }
|
88
88
|
|
89
89
|
it "clears previous changes" do
|
90
90
|
new_record = post.instantiate(record.to_hash)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
# For testing the DSL methods
|
4
4
|
module Another
|
@@ -17,19 +17,19 @@ describe ActiveRemote::DSL do
|
|
17
17
|
Tag.attr_publishable :guid
|
18
18
|
Tag.attr_publishable :name
|
19
19
|
|
20
|
-
expect(Tag.publishable_attributes).to match_array([
|
20
|
+
expect(Tag.publishable_attributes).to match_array([:guid, :name])
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe ".endpoints" do
|
25
25
|
it "has default values" do
|
26
|
-
expect(Tag.endpoints).to eq(
|
26
|
+
expect(Tag.endpoints).to eq(
|
27
27
|
:create => :create,
|
28
28
|
:delete => :delete,
|
29
29
|
:destroy => :destroy,
|
30
30
|
:search => :search,
|
31
31
|
:update => :update
|
32
|
-
|
32
|
+
)
|
33
33
|
end
|
34
34
|
|
35
35
|
context "given a new value for an endpoint" do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ::ActiveRemote::Integration do
|
4
4
|
let(:guid) { "GUID-derp" }
|
@@ -29,7 +29,7 @@ describe ::ActiveRemote::Integration do
|
|
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
|
-
twenty_o_one_one = subject[:updated_at] = DateTime.new(2001,
|
32
|
+
twenty_o_one_one = subject[:updated_at] = DateTime.new(2001, 0o1, 0o1)
|
33
33
|
expect(subject).to receive(:new_record?).and_return(false)
|
34
34
|
expect(subject.cache_key).to eq("tag/#{guid}-#{twenty_o_one_one.to_s(:number)}")
|
35
35
|
subject[:updated_at] = nil
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ::ActiveRemote::Persistence do
|
4
4
|
let(:response_without_errors) { ::HashWithIndifferentAccess.new(:errors => []) }
|
@@ -15,16 +15,16 @@ describe ::ActiveRemote::Persistence do
|
|
15
15
|
describe ".create" do
|
16
16
|
it "runs create callbacks" do
|
17
17
|
expect_any_instance_of(Tag).to receive(:after_create_callback)
|
18
|
-
Tag.create(:name =>
|
18
|
+
Tag.create(:name => "foo")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "initializes and saves a new record" do
|
22
22
|
expect_any_instance_of(Tag).to receive(:save)
|
23
|
-
Tag.create(:name =>
|
23
|
+
Tag.create(:name => "foo")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns a new record" do
|
27
|
-
value = Tag.create(:name =>
|
27
|
+
value = Tag.create(:name => "foo")
|
28
28
|
expect(value).to be_a(Tag)
|
29
29
|
end
|
30
30
|
end
|
@@ -32,14 +32,14 @@ describe ::ActiveRemote::Persistence do
|
|
32
32
|
describe ".create!" do
|
33
33
|
it "initializes and saves a new record" do
|
34
34
|
expect_any_instance_of(Tag).to receive(:save!)
|
35
|
-
Tag.create!(:name =>
|
35
|
+
Tag.create!(:name => "foo")
|
36
36
|
end
|
37
37
|
|
38
38
|
context "when the record has errors" do
|
39
39
|
before { allow_any_instance_of(Tag).to receive(:save!).and_raise(ActiveRemote::ActiveRemoteError) }
|
40
40
|
|
41
41
|
it "raises an exception" do
|
42
|
-
expect { Tag.create!(:name =>
|
42
|
+
expect { Tag.create!(:name => "foo") }.to raise_error(ActiveRemote::ActiveRemoteError)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -58,8 +58,8 @@ describe ::ActiveRemote::Persistence do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
context "when the response has errors" do
|
61
|
-
let(:error) { Generic::Error.new(:field =>
|
62
|
-
let(:response) { Generic::Remote::Tag.new(:errors => [
|
61
|
+
let(:error) { Generic::Error.new(:field => "name", :message => "Boom!") }
|
62
|
+
let(:response) { Generic::Remote::Tag.new(:errors => [error]) }
|
63
63
|
|
64
64
|
before { allow(rpc).to receive(:execute).and_return(response) }
|
65
65
|
|
@@ -81,8 +81,8 @@ describe ::ActiveRemote::Persistence do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
context "when an error occurs" do
|
84
|
-
let(:error) { Generic::Error.new(:field =>
|
85
|
-
let(:response) { Generic::Remote::Tag.new(:errors => [
|
84
|
+
let(:error) { Generic::Error.new(:field => "name", :message => "Boom!") }
|
85
|
+
let(:response) { Generic::Remote::Tag.new(:errors => [error]) }
|
86
86
|
|
87
87
|
before { allow(rpc).to receive(:execute).and_return(response) }
|
88
88
|
|
@@ -106,8 +106,8 @@ describe ::ActiveRemote::Persistence do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
context "when the response has errors" do
|
109
|
-
let(:error) { Generic::Error.new(:field =>
|
110
|
-
let(:response) { Generic::Remote::Tag.new(:errors => [
|
109
|
+
let(:error) { Generic::Error.new(:field => "name", :message => "Boom!") }
|
110
|
+
let(:response) { Generic::Remote::Tag.new(:errors => [error]) }
|
111
111
|
|
112
112
|
before { allow(rpc).to receive(:execute).and_return(response) }
|
113
113
|
|
@@ -129,8 +129,8 @@ describe ::ActiveRemote::Persistence do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
context "when an error occurs" do
|
132
|
-
let(:error) { Generic::Error.new(:field =>
|
133
|
-
let(:response) { Generic::Remote::Tag.new(:errors => [
|
132
|
+
let(:error) { Generic::Error.new(:field => "name", :message => "Boom!") }
|
133
|
+
let(:response) { Generic::Remote::Tag.new(:errors => [error]) }
|
134
134
|
|
135
135
|
before { allow(rpc).to receive(:execute).and_return(response) }
|
136
136
|
|
@@ -142,7 +142,7 @@ describe ::ActiveRemote::Persistence do
|
|
142
142
|
|
143
143
|
describe "#readonly?" do
|
144
144
|
context "when the record is created through instantiate with options[:readonly]" do
|
145
|
-
subject { Tag.instantiate({:guid =>
|
145
|
+
subject { Tag.instantiate({ :guid => "foo" }, :readonly => true) }
|
146
146
|
|
147
147
|
its(:new_record?) { should be_falsey }
|
148
148
|
its(:readonly?) { should be_truthy }
|
@@ -165,13 +165,13 @@ describe ::ActiveRemote::Persistence do
|
|
165
165
|
|
166
166
|
describe "#new_record?" do
|
167
167
|
context "when the record is created through instantiate" do
|
168
|
-
subject { Tag.instantiate(:guid =>
|
168
|
+
subject { Tag.instantiate(:guid => "foo") }
|
169
169
|
|
170
170
|
its(:new_record?) { should be_falsey }
|
171
171
|
end
|
172
172
|
|
173
173
|
context "when the record is persisted" do
|
174
|
-
subject { Tag.allocate.instantiate(:guid =>
|
174
|
+
subject { Tag.allocate.instantiate(:guid => "foo") }
|
175
175
|
|
176
176
|
its(:new_record?) { should be_falsey }
|
177
177
|
end
|
@@ -185,7 +185,7 @@ describe ::ActiveRemote::Persistence do
|
|
185
185
|
|
186
186
|
describe "#persisted?" do
|
187
187
|
context "when the record is persisted" do
|
188
|
-
subject { Tag.allocate.instantiate(:guid =>
|
188
|
+
subject { Tag.allocate.instantiate(:guid => "foo") }
|
189
189
|
|
190
190
|
its(:persisted?) { should be_truthy }
|
191
191
|
end
|
@@ -215,7 +215,7 @@ describe ::ActiveRemote::Persistence do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
context "when the record is not new" do
|
218
|
-
let(:attributes) { {
|
218
|
+
let(:attributes) { { "guid" => "foo" } }
|
219
219
|
|
220
220
|
subject { Tag.allocate.instantiate(attributes) }
|
221
221
|
|
@@ -259,16 +259,9 @@ describe ::ActiveRemote::Persistence do
|
|
259
259
|
end
|
260
260
|
|
261
261
|
context "when the record is not saved" do
|
262
|
-
let(:errors) {
|
263
|
-
[Generic::Error.new(:field => "name", :message => "Error one!"),
|
264
|
-
Generic::Error.new(:field => "name", :message => "Error two!")]
|
265
|
-
}
|
266
|
-
let(:response) { Generic::Remote::Tag.new(:errors => errors) }
|
267
|
-
before { allow(rpc).to receive(:execute).and_return(response) }
|
268
|
-
|
269
262
|
it "raises an exception" do
|
270
|
-
|
271
|
-
|
263
|
+
allow(subject).to receive(:save).and_return(false)
|
264
|
+
expect { subject.save! }.to raise_error(ActiveRemote::RemoteRecordNotSaved)
|
272
265
|
end
|
273
266
|
end
|
274
267
|
end
|
@@ -288,7 +281,7 @@ describe ::ActiveRemote::Persistence do
|
|
288
281
|
end
|
289
282
|
|
290
283
|
describe "#update_attribute" do
|
291
|
-
let(:tag) { Tag.allocate.instantiate(
|
284
|
+
let(:tag) { Tag.allocate.instantiate(:guid => "123") }
|
292
285
|
|
293
286
|
it "runs update callbacks" do
|
294
287
|
expect(tag).to receive(:after_update_callback)
|
@@ -296,7 +289,7 @@ describe ::ActiveRemote::Persistence do
|
|
296
289
|
end
|
297
290
|
|
298
291
|
it "updates a remote record" do
|
299
|
-
expect(rpc).to receive(:execute).with(:update,
|
292
|
+
expect(rpc).to receive(:execute).with(:update, "name" => "foo", "guid" => "123")
|
300
293
|
tag.update_attribute(:name, "foo")
|
301
294
|
end
|
302
295
|
|
@@ -315,8 +308,8 @@ describe ::ActiveRemote::Persistence do
|
|
315
308
|
end
|
316
309
|
|
317
310
|
describe "#update_attributes" do
|
318
|
-
let(:attributes) { HashWithIndifferentAccess.new(:name =>
|
319
|
-
let(:tag) { Tag.allocate.instantiate(
|
311
|
+
let(:attributes) { HashWithIndifferentAccess.new(:name => "bar") }
|
312
|
+
let(:tag) { Tag.allocate.instantiate(:guid => "123") }
|
320
313
|
|
321
314
|
it "runs update callbacks" do
|
322
315
|
expect(tag).to receive(:after_update_callback)
|
@@ -343,7 +336,7 @@ describe ::ActiveRemote::Persistence do
|
|
343
336
|
end
|
344
337
|
|
345
338
|
describe "#update_attributes!" do
|
346
|
-
let(:attributes) { HashWithIndifferentAccess.new(:name =>
|
339
|
+
let(:attributes) { HashWithIndifferentAccess.new(:name => "bar") }
|
347
340
|
|
348
341
|
before { allow(subject).to receive(:save!) }
|
349
342
|
after { allow(subject).to receive(:save!).and_call_original }
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ActiveRemote::PrimaryKey do
|
4
|
-
let(:tag) { Tag.new(:id =>
|
4
|
+
let(:tag) { Tag.new(:id => "1234", :guid => "TAG-123", :user_guid => "USR-123") }
|
5
5
|
|
6
6
|
after { Tag.instance_variable_set :@primary_key, nil }
|
7
7
|
|
8
8
|
describe ".default_primary_key" do
|
9
|
-
it
|
9
|
+
it "returns array of :guid" do
|
10
10
|
expect(Tag.default_primary_key).to eq(:guid)
|
11
11
|
end
|
12
12
|
end
|
@@ -47,125 +47,5 @@ describe ::ActiveRemote::QueryAttributes do
|
|
47
47
|
subject.name = 1
|
48
48
|
expect(subject.name?).to eq true
|
49
49
|
end
|
50
|
-
|
51
|
-
it "is false when the attribute is 0.0" do
|
52
|
-
subject.name = 0.0
|
53
|
-
expect(subject.name?).to eq false
|
54
|
-
end
|
55
|
-
|
56
|
-
it "is true when the attribute is 0.1" do
|
57
|
-
subject.name = 0.1
|
58
|
-
expect(subject.name?).to eq true
|
59
|
-
end
|
60
|
-
|
61
|
-
it "is false when the attribute is a zero BigDecimal" do
|
62
|
-
subject.name = BigDecimal.new("0.0")
|
63
|
-
expect(subject.name?).to eq false
|
64
|
-
end
|
65
|
-
|
66
|
-
it "is true when the attribute is a non-zero BigDecimal" do
|
67
|
-
subject.name = BigDecimal.new("0.1")
|
68
|
-
expect(subject.name?).to eq true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "is true when the attribute is -1" do
|
72
|
-
subject.name = -1
|
73
|
-
expect(subject.name?).to eq true
|
74
|
-
end
|
75
|
-
|
76
|
-
it "is false when the attribute is -0.0" do
|
77
|
-
subject.name = -0.0
|
78
|
-
expect(subject.name?).to eq false
|
79
|
-
end
|
80
|
-
|
81
|
-
it "is true when the attribute is -0.1" do
|
82
|
-
subject.name = -0.1
|
83
|
-
expect(subject.name?).to eq true
|
84
|
-
end
|
85
|
-
|
86
|
-
it "is false when the attribute is a negative zero BigDecimal" do
|
87
|
-
subject.name = BigDecimal.new("-0.0")
|
88
|
-
expect(subject.name?).to eq false
|
89
|
-
end
|
90
|
-
|
91
|
-
it "is true when the attribute is a negative BigDecimal" do
|
92
|
-
subject.name = BigDecimal.new("-0.1")
|
93
|
-
expect(subject.name?).to eq true
|
94
|
-
end
|
95
|
-
|
96
|
-
it "is false when the attribute is '0'" do
|
97
|
-
subject.name = "0"
|
98
|
-
expect(subject.name?).to eq false
|
99
|
-
end
|
100
|
-
|
101
|
-
it "is true when the attribute is '1'" do
|
102
|
-
subject.name = "1"
|
103
|
-
expect(subject.name?).to eq true
|
104
|
-
end
|
105
|
-
|
106
|
-
it "is false when the attribute is '0.0'" do
|
107
|
-
subject.name = "0.0"
|
108
|
-
expect(subject.name?).to eq false
|
109
|
-
end
|
110
|
-
|
111
|
-
it "is true when the attribute is '0.1'" do
|
112
|
-
subject.name = "0.1"
|
113
|
-
expect(subject.name?).to eq true
|
114
|
-
end
|
115
|
-
|
116
|
-
it "is true when the attribute is '-1'" do
|
117
|
-
subject.name = "-1"
|
118
|
-
expect(subject.name?).to eq true
|
119
|
-
end
|
120
|
-
|
121
|
-
it "is false when the attribute is '-0.0'" do
|
122
|
-
subject.name = "-0.0"
|
123
|
-
expect(subject.name?).to eq false
|
124
|
-
end
|
125
|
-
|
126
|
-
it "is true when the attribute is '-0.1'" do
|
127
|
-
subject.name = "-0.1"
|
128
|
-
expect(subject.name?).to eq true
|
129
|
-
end
|
130
|
-
|
131
|
-
it "is true when the attribute is 'true'" do
|
132
|
-
subject.name = "true"
|
133
|
-
expect(subject.name?).to eq true
|
134
|
-
end
|
135
|
-
|
136
|
-
it "is false when the attribute is 'false'" do
|
137
|
-
subject.name = "false"
|
138
|
-
expect(subject.name?).to eq false
|
139
|
-
end
|
140
|
-
|
141
|
-
it "is true when the attribute is 't'" do
|
142
|
-
subject.name = "t"
|
143
|
-
expect(subject.name?).to eq true
|
144
|
-
end
|
145
|
-
|
146
|
-
it "is false when the attribute is 'f'" do
|
147
|
-
subject.name = "f"
|
148
|
-
expect(subject.name?).to eq false
|
149
|
-
end
|
150
|
-
|
151
|
-
it "is true when the attribute is 'T'" do
|
152
|
-
subject.name = "T"
|
153
|
-
expect(subject.name?).to eq true
|
154
|
-
end
|
155
|
-
|
156
|
-
it "is false when the attribute is 'F'" do
|
157
|
-
subject.name = "F"
|
158
|
-
expect(subject.name?).to eq false
|
159
|
-
end
|
160
|
-
|
161
|
-
it "is true when the attribute is 'TRUE'" do
|
162
|
-
subject.name = "TRUE"
|
163
|
-
expect(subject.name?).to eq true
|
164
|
-
end
|
165
|
-
|
166
|
-
it "is false when the attribute is 'FALSE" do
|
167
|
-
subject.name = "FALSE"
|
168
|
-
expect(subject.name?).to eq false
|
169
|
-
end
|
170
50
|
end
|
171
51
|
end
|