active_attr 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of active_attr might be problematic. Click here for more details.
- data/.travis.yml +11 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -6
- data/README.md +29 -11
- data/active_attr.gemspec +3 -3
- data/gemfiles/rails_3_2.gemfile +11 -0
- data/gemfiles/rails_head.gemfile +3 -0
- data/lib/active_attr.rb +0 -1
- data/lib/active_attr/mass_assignment.rb +30 -2
- data/lib/active_attr/matchers/have_attribute_matcher.rb +17 -4
- data/lib/active_attr/model.rb +2 -2
- data/lib/active_attr/typecasting/big_decimal_typecaster.rb +2 -0
- data/lib/active_attr/typecasting/date_typecaster.rb +1 -1
- data/lib/active_attr/version.rb +1 -1
- data/spec/functional/active_attr/attribute_defaults_spec.rb +12 -12
- data/spec/functional/active_attr/attributes_spec.rb +12 -12
- data/spec/functional/active_attr/chainable_initialization_spec.rb +3 -3
- data/spec/functional/active_attr/mass_assignment_spec.rb +125 -0
- data/spec/functional/active_attr/matchers/have_attribute_matcher_spec.rb +147 -66
- data/spec/functional/active_attr/model_spec.rb +27 -19
- data/spec/functional/active_attr/serialization_spec.rb +5 -5
- data/spec/functional/active_attr/typecasted_attributes_spec.rb +45 -45
- data/spec/support/mass_assignment_shared_examples.rb +12 -12
- data/spec/unit/active_attr/attribute_defaults_spec.rb +6 -6
- data/spec/unit/active_attr/attribute_definition_spec.rb +6 -6
- data/spec/unit/active_attr/attributes_spec.rb +38 -38
- data/spec/unit/active_attr/logger_spec.rb +16 -16
- data/spec/unit/active_attr/mass_assignment_spec.rb +1 -1
- data/spec/unit/active_attr/matchers_spec.rb +3 -4
- data/spec/unit/active_attr/query_attributes_spec.rb +75 -75
- data/spec/unit/active_attr/typecasted_attributes_spec.rb +10 -10
- data/spec/unit/active_attr/typecasting/big_decimal_typecaster_spec.rb +9 -7
- data/spec/unit/active_attr/typecasting/boolean_typecaster_spec.rb +27 -25
- data/spec/unit/active_attr/typecasting/date_time_typecaster_spec.rb +12 -10
- data/spec/unit/active_attr/typecasting/date_typecaster_spec.rb +14 -12
- data/spec/unit/active_attr/typecasting/float_typecaster_spec.rb +6 -4
- data/spec/unit/active_attr/typecasting/integer_typecaster_spec.rb +8 -6
- data/spec/unit/active_attr/typecasting/object_typecaster_spec.rb +3 -1
- data/spec/unit/active_attr/typecasting/string_typecaster_spec.rb +5 -3
- data/spec/unit/active_attr/typecasting_spec.rb +3 -5
- data/spec/unit/active_attr/version_spec.rb +5 -5
- metadata +20 -17
- data/lib/active_attr/mass_assignment_security.rb +0 -54
- data/spec/functional/active_attr/mass_assignment_security_spec.rb +0 -45
- data/spec/unit/active_attr/mass_assignment_security_spec.rb +0 -67
@@ -3,7 +3,7 @@ require "active_attr/attributes"
|
|
3
3
|
|
4
4
|
module ActiveAttr
|
5
5
|
describe Attributes do
|
6
|
-
subject { model_class.new }
|
6
|
+
subject(:model) { model_class.new }
|
7
7
|
let(:last_name) { "Poweski" }
|
8
8
|
|
9
9
|
let :model_class do
|
@@ -69,23 +69,23 @@ module ActiveAttr
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "defines an attribute reader that calls #attribute" do
|
72
|
-
|
73
|
-
|
72
|
+
model.should_receive(:attribute).with("first_name")
|
73
|
+
model.first_name
|
74
74
|
end
|
75
75
|
|
76
76
|
it "defines an attribute reader that can be called via super" do
|
77
|
-
|
78
|
-
|
77
|
+
model.should_receive(:attribute).with("amount")
|
78
|
+
model.amount
|
79
79
|
end
|
80
80
|
|
81
81
|
it "defines an attribute writer that calls #attribute=" do
|
82
|
-
|
83
|
-
|
82
|
+
model.should_receive(:attribute=).with("first_name", "Ben")
|
83
|
+
model.first_name = "Ben"
|
84
84
|
end
|
85
85
|
|
86
86
|
it "defines an attribute writer that can be called via super" do
|
87
|
-
|
88
|
-
|
87
|
+
model.should_receive(:attribute=).with("amount", 1)
|
88
|
+
model.amount = 1
|
89
89
|
end
|
90
90
|
|
91
91
|
it "defining an attribute twice does not give the class two attribute definitions" do
|
@@ -121,17 +121,17 @@ module ActiveAttr
|
|
121
121
|
|
122
122
|
it "defines an attribute reader that calls #attribute" do
|
123
123
|
attributeless.attribute! :first_name
|
124
|
-
|
124
|
+
model = attributeless.new
|
125
125
|
result = mock
|
126
|
-
|
127
|
-
|
126
|
+
model.should_receive(:attribute).with("first_name").and_return(result)
|
127
|
+
model.first_name.should equal result
|
128
128
|
end
|
129
129
|
|
130
130
|
it "defines an attribute writer that calls #attribute=" do
|
131
131
|
attributeless.attribute! :first_name
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
model = attributeless.new
|
133
|
+
model.should_receive(:attribute=).with("first_name", "Ben")
|
134
|
+
model.first_name = "Ben"
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -186,32 +186,32 @@ module ActiveAttr
|
|
186
186
|
|
187
187
|
context "when an attribute is defined" do
|
188
188
|
it "returns the key value pairs" do
|
189
|
-
|
190
|
-
|
189
|
+
model.first_name = "Ben"
|
190
|
+
model.attributes.should include("first_name" => "Ben")
|
191
191
|
end
|
192
192
|
|
193
193
|
it "returns a new Hash " do
|
194
|
-
|
195
|
-
|
194
|
+
model.attributes.merge!("first_name" => "Bob")
|
195
|
+
model.attributes.should_not include("first_name" => "Bob")
|
196
196
|
end
|
197
197
|
|
198
198
|
it "returns all attributes" do
|
199
|
-
|
199
|
+
model.attributes.keys.should =~ %w(amount first_name last_name)
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
203
|
context "when a getter is overridden" do
|
204
204
|
it "uses the overridden implementation" do
|
205
|
-
|
205
|
+
model.attributes.should include("last_name" => last_name)
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
210
|
describe "#inspect" do
|
211
|
-
before {
|
211
|
+
before { model.first_name = "Ben" }
|
212
212
|
|
213
213
|
it "includes the class name and all attribute values in alphabetical order by attribute name" do
|
214
|
-
|
214
|
+
model.inspect.should == %{#<Foo amount: nil, first_name: "Ben", last_name: "#{last_name}">}
|
215
215
|
end
|
216
216
|
|
217
217
|
it "doesn't format the inspection string for attributes if the model does not have any" do
|
@@ -220,7 +220,7 @@ module ActiveAttr
|
|
220
220
|
|
221
221
|
context "when a getter is overridden" do
|
222
222
|
it "uses the overridden implementation" do
|
223
|
-
|
223
|
+
model.inspect.should include %{last_name: "#{last_name}"}
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
@@ -229,33 +229,33 @@ module ActiveAttr
|
|
229
229
|
describe "##{method}" do
|
230
230
|
context "when an attribute is not set" do
|
231
231
|
it "returns nil" do
|
232
|
-
|
232
|
+
model.send(method, :first_name).should be_nil
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
236
|
context "when an attribute is set" do
|
237
237
|
let(:first_name) { "Bob" }
|
238
238
|
|
239
|
-
before {
|
239
|
+
before { model.write_attribute(:first_name, first_name) }
|
240
240
|
|
241
241
|
it "returns the attribute using a Symbol" do
|
242
|
-
|
242
|
+
model.send(method, :first_name).should == first_name
|
243
243
|
end
|
244
244
|
|
245
245
|
it "returns the attribute using a String" do
|
246
|
-
|
246
|
+
model.send(method, 'first_name').should == first_name
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
250
|
context "when the getter is overridden" do
|
251
251
|
it "uses the overridden implementation" do
|
252
|
-
|
252
|
+
model.send(method, :last_name).should == last_name
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
256
|
it "raises when getting an undefined attribute" do
|
257
257
|
expect do
|
258
|
-
|
258
|
+
model.send(method, :initials)
|
259
259
|
end.to raise_error UnknownAttributeError, "unknown attribute: initials"
|
260
260
|
end
|
261
261
|
end
|
@@ -264,33 +264,33 @@ module ActiveAttr
|
|
264
264
|
[:[]=, :write_attribute].each do |method|
|
265
265
|
describe "##{method}" do
|
266
266
|
it "raises ArgumentError with one argument" do
|
267
|
-
expect {
|
267
|
+
expect { model.send(method, :first_name) }.to raise_error(ArgumentError)
|
268
268
|
end
|
269
269
|
|
270
270
|
it "raises ArgumentError with no arguments" do
|
271
|
-
expect {
|
271
|
+
expect { model.send(method) }.to raise_error(ArgumentError)
|
272
272
|
end
|
273
273
|
|
274
274
|
it "sets an attribute using a Symbol and value" do
|
275
|
-
expect {
|
275
|
+
expect { model.send(method, :first_name, "Ben") }.to change { model.attributes["first_name"] }.from(nil).to("Ben")
|
276
276
|
end
|
277
277
|
|
278
278
|
it "sets an attribute using a String and value" do
|
279
|
-
expect {
|
279
|
+
expect { model.send(method, 'first_name', "Ben") }.to change { model.attributes["first_name"] }.from(nil).to("Ben")
|
280
280
|
end
|
281
281
|
|
282
282
|
it "is able to set an attribute to nil" do
|
283
|
-
|
284
|
-
expect {
|
283
|
+
model.first_name = "Ben"
|
284
|
+
expect { model.send(method, :first_name, nil) }.to change { model.attributes["first_name"] }.from("Ben").to(nil)
|
285
285
|
end
|
286
286
|
|
287
287
|
it "uses the overridden implementation when the setter is overridden" do
|
288
|
-
|
288
|
+
model.send(method, :last_name, "poweski").should == "POWESKI"
|
289
289
|
end
|
290
290
|
|
291
291
|
it "raises when setting an undefined attribute" do
|
292
292
|
expect do
|
293
|
-
|
293
|
+
model.send(method, :initials, "BP")
|
294
294
|
end.to raise_error UnknownAttributeError, "unknown attribute: initials"
|
295
295
|
end
|
296
296
|
end
|
@@ -3,7 +3,7 @@ require "active_attr/logger"
|
|
3
3
|
|
4
4
|
module ActiveAttr
|
5
5
|
describe Logger do
|
6
|
-
subject { model_class.new }
|
6
|
+
subject(:model) { model_class.new }
|
7
7
|
let(:logger) { double "logger" }
|
8
8
|
let(:child_class) { Class.new(parent_class) }
|
9
9
|
let(:parent_class) { model_class }
|
@@ -32,11 +32,11 @@ module ActiveAttr
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "#logger is nil" do
|
35
|
-
|
35
|
+
model.logger.should be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "#logger? is false" do
|
39
|
-
|
39
|
+
model.logger?.should == false
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -61,11 +61,11 @@ module ActiveAttr
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "#logger is the logger" do
|
64
|
-
|
64
|
+
model.logger.should == logger
|
65
65
|
end
|
66
66
|
|
67
67
|
it "#logger? is true" do
|
68
|
-
|
68
|
+
model.logger?.should == true
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -89,17 +89,17 @@ module ActiveAttr
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "#logger is the logger" do
|
92
|
-
|
92
|
+
model.logger.should == logger
|
93
93
|
end
|
94
94
|
|
95
95
|
it "#logger? is true" do
|
96
|
-
|
96
|
+
model.logger?.should == true
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
context "when the logger is set on a parent class" do
|
101
101
|
before { parent_class.logger = logger }
|
102
|
-
subject { child_class.new }
|
102
|
+
subject(:model) { child_class.new }
|
103
103
|
|
104
104
|
it "#{described_class}.logger is nil" do
|
105
105
|
described_class.logger.should be_nil
|
@@ -118,17 +118,17 @@ module ActiveAttr
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "#logger is the logger" do
|
121
|
-
|
121
|
+
model.logger.should == logger
|
122
122
|
end
|
123
123
|
|
124
124
|
it "#logger? is true" do
|
125
|
-
|
125
|
+
model.logger?.should == true
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
129
|
context "when the logger is set on a child class" do
|
130
130
|
before { child_class.logger = logger }
|
131
|
-
subject { parent_class.new }
|
131
|
+
subject(:model) { parent_class.new }
|
132
132
|
|
133
133
|
it "#{described_class}.logger is nil" do
|
134
134
|
described_class.logger.should be_nil
|
@@ -147,16 +147,16 @@ module ActiveAttr
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it "#logger is nil" do
|
150
|
-
|
150
|
+
model.logger.should be_nil
|
151
151
|
end
|
152
152
|
|
153
153
|
it "#logger? is false" do
|
154
|
-
|
154
|
+
model.logger?.should == false
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
context "when the logger is set on the instance" do
|
159
|
-
before {
|
159
|
+
before { model.logger = logger }
|
160
160
|
|
161
161
|
it "#{described_class}.logger is nil" do
|
162
162
|
described_class.logger.should be_nil
|
@@ -175,11 +175,11 @@ module ActiveAttr
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "#logger is the logger" do
|
178
|
-
|
178
|
+
model.logger.should == logger
|
179
179
|
end
|
180
180
|
|
181
181
|
it "#logger? is true" do
|
182
|
-
|
182
|
+
model.logger?.should == true
|
183
183
|
end
|
184
184
|
end
|
185
185
|
end
|
@@ -3,20 +3,19 @@ require "active_attr/matchers"
|
|
3
3
|
|
4
4
|
module ActiveAttr
|
5
5
|
describe Matchers do
|
6
|
-
|
7
|
-
subject { dsl }
|
6
|
+
subject(:dsl) { Object.new.extend described_class }
|
8
7
|
|
9
8
|
it { should respond_to(:have_attribute).with(1).argument }
|
10
9
|
|
11
10
|
describe "#have_attribute" do
|
12
|
-
subject { dsl.have_attribute(:first_name) }
|
11
|
+
subject(:matcher) { dsl.have_attribute(:first_name) }
|
13
12
|
|
14
13
|
it "builds a HaveAttributeMatcher" do
|
15
14
|
should be_a_kind_of Matchers::HaveAttributeMatcher
|
16
15
|
end
|
17
16
|
|
18
17
|
it "uses the given attribute name to construct the matcher" do
|
19
|
-
|
18
|
+
matcher.send(:attribute_name).should == :first_name
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -4,7 +4,7 @@ require "bigdecimal"
|
|
4
4
|
|
5
5
|
module ActiveAttr
|
6
6
|
describe QueryAttributes do
|
7
|
-
subject { model_class.new }
|
7
|
+
subject(:model) { model_class.new }
|
8
8
|
|
9
9
|
let :model_class do
|
10
10
|
Class.new do
|
@@ -29,196 +29,196 @@ module ActiveAttr
|
|
29
29
|
|
30
30
|
describe ".attribute" do
|
31
31
|
it "defines an attribute predicate method that calls #attribute?" do
|
32
|
-
|
33
|
-
|
32
|
+
model.should_receive(:attribute?).with("value")
|
33
|
+
model.value?
|
34
34
|
end
|
35
35
|
|
36
36
|
it "defines an attribute reader that can be called via super" do
|
37
|
-
|
38
|
-
|
37
|
+
model.should_receive(:attribute?).with("overridden")
|
38
|
+
model.overridden?
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "#query_attribute" do
|
43
43
|
it "raises ArgumentError when called with two arguments" do
|
44
|
-
expect {
|
44
|
+
expect { model.query_attribute(:a, :b) }.to raise_error ArgumentError
|
45
45
|
end
|
46
46
|
|
47
47
|
it "does not raise when called with a single argument" do
|
48
|
-
expect {
|
48
|
+
expect { model.query_attribute(:a) }.not_to raise_error ArgumentError
|
49
49
|
end
|
50
50
|
|
51
51
|
it "raises ArgumentError when called with no arguments" do
|
52
|
-
expect {
|
52
|
+
expect { model.query_attribute }.to raise_error ArgumentError
|
53
53
|
end
|
54
54
|
|
55
55
|
it "calls the predicate method if defined" do
|
56
|
-
|
57
|
-
|
56
|
+
model.query_attribute(:true).should eq true
|
57
|
+
model.query_attribute(:false).should == false
|
58
58
|
end
|
59
59
|
|
60
60
|
it "raises when getting an undefined attribute" do
|
61
|
-
expect {
|
61
|
+
expect { model.query_attribute(:initials) }.to raise_error UnknownAttributeError, "unknown attribute: initials"
|
62
62
|
end
|
63
63
|
|
64
64
|
it "is false when the attribute is false" do
|
65
|
-
|
66
|
-
|
65
|
+
model.value = false
|
66
|
+
model.value?.should == false
|
67
67
|
end
|
68
68
|
|
69
69
|
it "is true when the attribute is true" do
|
70
|
-
|
71
|
-
|
70
|
+
model.value = true
|
71
|
+
model.value?.should == true
|
72
72
|
end
|
73
73
|
|
74
74
|
it "is false when the attribute is nil" do
|
75
|
-
|
76
|
-
|
75
|
+
model.value = nil
|
76
|
+
model.value?.should == false
|
77
77
|
end
|
78
78
|
|
79
79
|
it "is true when the attribute is an Object" do
|
80
|
-
|
81
|
-
|
80
|
+
model.value = Object.new
|
81
|
+
model.value?.should == true
|
82
82
|
end
|
83
83
|
|
84
84
|
it "is false when the attribute is an empty string" do
|
85
|
-
|
86
|
-
|
85
|
+
model.value = ""
|
86
|
+
model.value?.should == false
|
87
87
|
end
|
88
88
|
|
89
89
|
it "is true when the attribute is a non-empty string" do
|
90
|
-
|
91
|
-
|
90
|
+
model.value = "Chris"
|
91
|
+
model.value?.should == true
|
92
92
|
end
|
93
93
|
|
94
94
|
it "is false when the attribute is 0" do
|
95
|
-
|
96
|
-
|
95
|
+
model.value = 0
|
96
|
+
model.value?.should == false
|
97
97
|
end
|
98
98
|
|
99
99
|
it "is true when the attribute is 1" do
|
100
|
-
|
101
|
-
|
100
|
+
model.value = 1
|
101
|
+
model.value?.should == true
|
102
102
|
end
|
103
103
|
|
104
104
|
it "is false when the attribute is 0.0" do
|
105
|
-
|
106
|
-
|
105
|
+
model.value = 0.0
|
106
|
+
model.value?.should == false
|
107
107
|
end
|
108
108
|
|
109
109
|
it "is true when the attribute is 0.1" do
|
110
|
-
|
111
|
-
|
110
|
+
model.value = 0.1
|
111
|
+
model.value?.should == true
|
112
112
|
end
|
113
113
|
|
114
114
|
it "is false when the attribute is a zero BigDecimal" do
|
115
|
-
|
116
|
-
|
115
|
+
model.value = BigDecimal.new("0.0")
|
116
|
+
model.value?.should == false
|
117
117
|
end
|
118
118
|
|
119
119
|
it "is true when the attribute is a non-zero BigDecimal" do
|
120
|
-
|
121
|
-
|
120
|
+
model.value = BigDecimal.new("0.1")
|
121
|
+
model.value?.should == true
|
122
122
|
end
|
123
123
|
|
124
124
|
it "is true when the attribute is -1" do
|
125
|
-
|
126
|
-
|
125
|
+
model.value = -1
|
126
|
+
model.value?.should == true
|
127
127
|
end
|
128
128
|
|
129
129
|
it "is false when the attribute is -0.0" do
|
130
|
-
|
131
|
-
|
130
|
+
model.value = -0.0
|
131
|
+
model.value?.should == false
|
132
132
|
end
|
133
133
|
|
134
134
|
it "is true when the attribute is -0.1" do
|
135
|
-
|
136
|
-
|
135
|
+
model.value = -0.1
|
136
|
+
model.value?.should == true
|
137
137
|
end
|
138
138
|
|
139
139
|
it "is false when the attribute is a negative zero BigDecimal" do
|
140
|
-
|
141
|
-
|
140
|
+
model.value = BigDecimal.new("-0.0")
|
141
|
+
model.value?.should == false
|
142
142
|
end
|
143
143
|
|
144
144
|
it "is true when the attribute is a negative BigDecimal" do
|
145
|
-
|
146
|
-
|
145
|
+
model.value = BigDecimal.new("-0.1")
|
146
|
+
model.value?.should == true
|
147
147
|
end
|
148
148
|
|
149
149
|
it "is false when the attribute is '0'" do
|
150
|
-
|
151
|
-
|
150
|
+
model.value = "0"
|
151
|
+
model.value?.should == false
|
152
152
|
end
|
153
153
|
|
154
154
|
it "is true when the attribute is '1'" do
|
155
|
-
|
156
|
-
|
155
|
+
model.value = "1"
|
156
|
+
model.value?.should == true
|
157
157
|
end
|
158
158
|
|
159
159
|
it "is false when the attribute is '0.0'" do
|
160
|
-
|
161
|
-
|
160
|
+
model.value = "0.0"
|
161
|
+
model.value?.should == false
|
162
162
|
end
|
163
163
|
|
164
164
|
it "is true when the attribute is '0.1'" do
|
165
|
-
|
166
|
-
|
165
|
+
model.value = "0.1"
|
166
|
+
model.value?.should == true
|
167
167
|
end
|
168
168
|
|
169
169
|
it "is true when the attribute is '-1'" do
|
170
|
-
|
171
|
-
|
170
|
+
model.value = "-1"
|
171
|
+
model.value?.should == true
|
172
172
|
end
|
173
173
|
|
174
174
|
it "is false when the attribute is '-0.0'" do
|
175
|
-
|
176
|
-
|
175
|
+
model.value = "-0.0"
|
176
|
+
model.value?.should == false
|
177
177
|
end
|
178
178
|
|
179
179
|
it "is true when the attribute is '-0.1'" do
|
180
|
-
|
181
|
-
|
180
|
+
model.value = "-0.1"
|
181
|
+
model.value?.should == true
|
182
182
|
end
|
183
183
|
|
184
184
|
it "is true when the attribute is 'true'" do
|
185
|
-
|
186
|
-
|
185
|
+
model.value = "true"
|
186
|
+
model.value?.should == true
|
187
187
|
end
|
188
188
|
|
189
189
|
it "is false when the attribute is 'false'" do
|
190
|
-
|
191
|
-
|
190
|
+
model.value = "false"
|
191
|
+
model.value?.should == false
|
192
192
|
end
|
193
193
|
|
194
194
|
it "is true when the attribute is 't'" do
|
195
|
-
|
196
|
-
|
195
|
+
model.value = "t"
|
196
|
+
model.value?.should == true
|
197
197
|
end
|
198
198
|
|
199
199
|
it "is false when the attribute is 'f'" do
|
200
|
-
|
201
|
-
|
200
|
+
model.value = "f"
|
201
|
+
model.value?.should == false
|
202
202
|
end
|
203
203
|
|
204
204
|
it "is true when the attribute is 'T'" do
|
205
|
-
|
206
|
-
|
205
|
+
model.value = "T"
|
206
|
+
model.value?.should == true
|
207
207
|
end
|
208
208
|
|
209
209
|
it "is false when the attribute is 'F'" do
|
210
|
-
|
211
|
-
|
210
|
+
model.value = "F"
|
211
|
+
model.value?.should == false
|
212
212
|
end
|
213
213
|
|
214
214
|
it "is true when the attribute is 'TRUE'" do
|
215
|
-
|
216
|
-
|
215
|
+
model.value = "TRUE"
|
216
|
+
model.value?.should == true
|
217
217
|
end
|
218
218
|
|
219
219
|
it "is false when the attribute is 'FALSE" do
|
220
|
-
|
221
|
-
|
220
|
+
model.value = "FALSE"
|
221
|
+
model.value?.should == false
|
222
222
|
end
|
223
223
|
end
|
224
224
|
end
|