ardm 0.0.1 → 0.1.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.
- checksums.yaml +5 -13
- data/Gemfile +1 -2
- data/LICENSE +2 -2
- data/README.md +72 -16
- data/ardm.gemspec +1 -0
- data/lib/ardm.rb +2 -1
- data/lib/ardm/active_record.rb +8 -1
- data/lib/ardm/active_record/associations.rb +33 -4
- data/lib/ardm/active_record/base.rb +2 -0
- data/lib/ardm/active_record/collection.rb +5 -0
- data/lib/ardm/active_record/data_mapper_constant.rb +1 -0
- data/lib/ardm/active_record/data_mapper_constant_proxy.rb +24 -0
- data/lib/ardm/active_record/finalize.rb +18 -0
- data/lib/ardm/active_record/predicate_builder/array_handler.rb +10 -16
- data/lib/ardm/active_record/predicate_builder/rails3.rb +42 -15
- data/lib/ardm/active_record/predicate_builder/rails4.rb +39 -13
- data/lib/ardm/active_record/property.rb +24 -12
- data/lib/ardm/active_record/query.rb +9 -18
- data/lib/ardm/active_record/record.rb +54 -11
- data/lib/ardm/active_record/relation.rb +36 -6
- data/lib/ardm/active_record/repository.rb +6 -2
- data/lib/ardm/data_mapper.rb +2 -0
- data/lib/ardm/data_mapper/record.rb +3 -9
- data/lib/ardm/version.rb +1 -1
- data/spec/ardm/datamapper_constants_spec.rb +31 -0
- data/spec/fixtures/article.rb +2 -0
- data/spec/integration/api_key_spec.rb +3 -3
- data/spec/integration/bcrypt_hash_spec.rb +7 -7
- data/spec/integration/comma_separated_list_spec.rb +11 -11
- data/spec/integration/dirty_minder_spec.rb +23 -39
- data/spec/integration/enum_spec.rb +11 -11
- data/spec/integration/epoch_time_spec.rb +6 -6
- data/spec/integration/file_path_spec.rb +23 -23
- data/spec/integration/flag_spec.rb +11 -13
- data/spec/integration/ip_address_spec.rb +15 -15
- data/spec/integration/json_spec.rb +7 -7
- data/spec/integration/slug_spec.rb +6 -6
- data/spec/integration/uri_spec.rb +11 -11
- data/spec/integration/uuid_spec.rb +16 -16
- data/spec/integration/yaml_spec.rb +8 -8
- data/spec/public/model_spec.rb +193 -0
- data/spec/public/property/binary_spec.rb +4 -4
- data/spec/public/property/boolean_spec.rb +3 -3
- data/spec/public/property/class_spec.rb +2 -2
- data/spec/public/property/date_spec.rb +2 -2
- data/spec/public/property/date_time_spec.rb +2 -2
- data/spec/public/property/decimal_spec.rb +2 -2
- data/spec/public/property/discriminator_spec.rb +21 -20
- data/spec/public/property/float_spec.rb +2 -2
- data/spec/public/property/integer_spec.rb +2 -2
- data/spec/public/property/object_spec.rb +14 -13
- data/spec/public/property/serial_spec.rb +2 -2
- data/spec/public/property/string_spec.rb +2 -2
- data/spec/public/property/text_spec.rb +2 -2
- data/spec/public/property/time_spec.rb +2 -2
- data/spec/public/property_spec.rb +44 -48
- data/spec/public/resource_spec.rb +278 -0
- data/spec/schema.rb +33 -4
- data/spec/semipublic/property/boolean_spec.rb +5 -5
- data/spec/semipublic/property/class_spec.rb +3 -3
- data/spec/semipublic/property/date_spec.rb +8 -8
- data/spec/semipublic/property/date_time_spec.rb +9 -9
- data/spec/semipublic/property/decimal_spec.rb +16 -16
- data/spec/semipublic/property/float_spec.rb +16 -16
- data/spec/semipublic/property/integer_spec.rb +16 -16
- data/spec/semipublic/property/lookup_spec.rb +4 -4
- data/spec/semipublic/property/text_spec.rb +2 -2
- data/spec/semipublic/property/time_spec.rb +10 -10
- data/spec/semipublic/property_spec.rb +4 -4
- data/spec/shared/finder_shared_spec.rb +1151 -0
- data/spec/shared/flags_shared_spec.rb +6 -6
- data/spec/shared/identity_function_group.rb +1 -1
- data/spec/shared/public_property_spec.rb +26 -25
- data/spec/shared/resource_spec.rb +1218 -0
- data/spec/shared/semipublic_property_spec.rb +23 -22
- data/spec/spec_helper.rb +17 -0
- data/spec/unit/bcrypt_hash_spec.rb +15 -15
- data/spec/unit/csv_spec.rb +11 -11
- data/spec/unit/dirty_minder_spec.rb +3 -5
- data/spec/unit/enum_spec.rb +17 -17
- data/spec/unit/epoch_time_spec.rb +8 -8
- data/spec/unit/file_path_spec.rb +9 -9
- data/spec/unit/flag_spec.rb +9 -9
- data/spec/unit/ip_address_spec.rb +9 -9
- data/spec/unit/json_spec.rb +11 -11
- data/spec/unit/paranoid_boolean_spec.rb +19 -17
- data/spec/unit/paranoid_datetime_spec.rb +21 -19
- data/spec/unit/regexp_spec.rb +4 -4
- data/spec/unit/uri_spec.rb +8 -8
- data/spec/unit/yaml_spec.rb +9 -9
- metadata +35 -27
- data/lib/ardm/active_record/not_found.rb +0 -7
- data/lib/ardm/data_mapper/not_found.rb +0 -5
@@ -1,27 +1,28 @@
|
|
1
|
-
|
1
|
+
shared_examples 'A semipublic Property' do
|
2
2
|
module ::Blog
|
3
3
|
class Article < Ardm::Record
|
4
4
|
self.table_name = "articles"
|
5
5
|
property :id, Serial
|
6
|
+
timestamps :at
|
6
7
|
end
|
7
8
|
end
|
8
9
|
|
9
10
|
describe '.new' do
|
10
11
|
describe 'when provided no options' do
|
11
12
|
it 'should return a Property' do
|
12
|
-
property.
|
13
|
+
expect(property).to be_kind_of(type)
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'should set the load_as' do
|
16
|
-
property.load_as.
|
17
|
+
expect(property.load_as).to be(type.load_as)
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'should set the model' do
|
20
|
-
property.model.
|
21
|
+
expect(property.model).to equal(model)
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'should set the options to the default' do
|
24
|
-
property.options.
|
25
|
+
expect(property.options).to eq(type.options.merge(options))
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -32,19 +33,19 @@ share_examples_for 'A semipublic Property' do
|
|
32
33
|
let(:property) { type.new(model, name, options.merge(opts)) }
|
33
34
|
|
34
35
|
it 'should return a Property' do
|
35
|
-
property.
|
36
|
+
expect(property).to be_kind_of(type)
|
36
37
|
end
|
37
38
|
|
38
39
|
it 'should set the model' do
|
39
|
-
property.model.
|
40
|
+
expect(property.model).to equal(model)
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should set the load_as' do
|
43
|
-
property.load_as.
|
44
|
+
expect(property.load_as).to be(type.load_as)
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should set the options to #{opts.inspect}" do
|
47
|
-
property.options.
|
48
|
+
expect(property.options).to eq(type.options.merge(options.merge(opts)))
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -52,9 +53,9 @@ share_examples_for 'A semipublic Property' do
|
|
52
53
|
[ [], nil ].each do |value|
|
53
54
|
describe "when provided #{(invalid_options = { attribute => value }).inspect}" do
|
54
55
|
it 'should raise an exception' do
|
55
|
-
|
56
|
+
expect {
|
56
57
|
type.new(model, name, options.merge(invalid_options))
|
57
|
-
}.
|
58
|
+
}.to raise_error(ArgumentError, "options[#{attribute.inspect}] must be either true, false, a Symbol or an Array of Symbols")
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
@@ -65,21 +66,21 @@ share_examples_for 'A semipublic Property' do
|
|
65
66
|
subject { property.load(value) }
|
66
67
|
|
67
68
|
before do
|
68
|
-
property.
|
69
|
+
expect(property).to receive(:typecast).with(value).and_return(value)
|
69
70
|
end
|
70
71
|
|
71
|
-
it {
|
72
|
+
it { is_expected.to eql(value) }
|
72
73
|
end
|
73
74
|
|
74
75
|
describe "#typecast" do
|
75
76
|
describe 'when value is nil' do
|
76
77
|
it 'returns value unchanged' do
|
77
|
-
property.typecast(nil).
|
78
|
+
expect(property.typecast(nil)).to be(nil)
|
78
79
|
end
|
79
80
|
|
80
81
|
describe 'when value is a Ruby primitive' do
|
81
82
|
it 'returns value unchanged' do
|
82
|
-
property.typecast(value).
|
83
|
+
expect(property.typecast(value)).to eq(value)
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
@@ -88,27 +89,27 @@ share_examples_for 'A semipublic Property' do
|
|
88
89
|
describe '#valid?' do
|
89
90
|
describe 'when provided a valid value' do
|
90
91
|
it 'should return true' do
|
91
|
-
property.valid?(value).
|
92
|
+
expect(property.valid?(value)).to be(true)
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
96
|
describe 'when provide an invalid value' do
|
96
97
|
it 'should return false' do
|
97
|
-
property.valid?(invalid_value).
|
98
|
+
expect(property.valid?(invalid_value)).to be(false)
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
102
|
describe 'when provide a nil value when required' do
|
102
103
|
it 'should return false' do
|
103
104
|
property = type.new(model, name, options.merge(:required => true))
|
104
|
-
property.valid?(nil).
|
105
|
+
expect(property.valid?(nil)).to be(false)
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
109
|
describe 'when provide a nil value when not required' do
|
109
110
|
it 'should return false' do
|
110
111
|
property = type.new(model, name, options.merge(:required => false))
|
111
|
-
property.valid?(nil).
|
112
|
+
expect(property.valid?(nil)).to be(true)
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
@@ -121,14 +122,14 @@ share_examples_for 'A semipublic Property' do
|
|
121
122
|
shared_examples_for 'assert_valid_value on invalid value' do
|
122
123
|
it 'should raise Ardm::Property::InvalidValueError' do
|
123
124
|
expect { subject }.to(raise_error(Ardm::Property::InvalidValueError) do |error|
|
124
|
-
error.property.
|
125
|
+
expect(error.property).to eq(property)
|
125
126
|
end)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
130
|
describe 'when provided a valid value' do
|
130
131
|
it 'should return true' do
|
131
|
-
subject.
|
132
|
+
expect(subject).to be(true)
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
@@ -152,7 +153,7 @@ share_examples_for 'A semipublic Property' do
|
|
152
153
|
let(:value) { nil }
|
153
154
|
|
154
155
|
it 'should return true' do
|
155
|
-
subject.
|
156
|
+
expect(subject).to be(true)
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -38,6 +38,23 @@ RSpec.configure do |config|
|
|
38
38
|
config.after(:each) do
|
39
39
|
DatabaseCleaner.clean
|
40
40
|
end
|
41
|
+
|
42
|
+
def reset_raise_on_save_failure(object)
|
43
|
+
name = :raise_on_save_failure
|
44
|
+
ivar = "@#{name}"
|
45
|
+
|
46
|
+
if object.respond_to? :singleton_class
|
47
|
+
object.singleton_class.class_eval do
|
48
|
+
remove_possible_method(name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
object.instance_eval do
|
53
|
+
if instance_variable_defined?(ivar)
|
54
|
+
remove_instance_variable(ivar)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
41
58
|
end
|
42
59
|
|
43
60
|
DEPENDENCIES = {
|
@@ -30,11 +30,11 @@ try_spec do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'returns instance of BCrypt::Password' do
|
33
|
-
@result.
|
33
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'returns a string that is 60 characters long' do
|
37
|
-
@result.size.
|
37
|
+
expect(@result.size).to eq(60)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -45,7 +45,7 @@ try_spec do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'returns nil' do
|
48
|
-
@result.
|
48
|
+
expect(@result).to be_nil
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -58,11 +58,11 @@ try_spec do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'returns instance of BCrypt::Password' do
|
61
|
-
@result.
|
61
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'returns a string that matches original' do
|
65
|
-
@result.
|
65
|
+
expect(@result).to eq(@clear_password)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -73,7 +73,7 @@ try_spec do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns nil' do
|
76
|
-
@result.
|
76
|
+
expect(@result).to be_nil
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -86,11 +86,11 @@ try_spec do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'casts argument to BCrypt::Password' do
|
89
|
-
@result.
|
89
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'casts argument to value that matches input' do
|
93
|
-
@result.
|
93
|
+
expect(@result).to eq(@input)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -101,11 +101,11 @@ try_spec do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'casts argument to BCrypt::Password' do
|
104
|
-
@result.
|
104
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'casts argument to value that matches input' do
|
108
|
-
@result.
|
108
|
+
expect(@result).to eq(@input)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -116,11 +116,11 @@ try_spec do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'casts argument to BCrypt::Password' do
|
119
|
-
@result.
|
119
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'casts argument to value that matches input' do
|
123
|
-
@result.
|
123
|
+
expect(@result).to eq(@input)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -131,11 +131,11 @@ try_spec do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'casts argument to BCrypt::Password' do
|
134
|
-
@result.
|
134
|
+
expect(@result).to be_an_instance_of(BCrypt::Password)
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'casts argument to value that matches input' do
|
138
|
-
@result.
|
138
|
+
expect(@result).to eq(@input)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -146,7 +146,7 @@ try_spec do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'returns nil' do
|
149
|
-
@result.
|
149
|
+
expect(@result).to be_nil
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
data/spec/unit/csv_spec.rb
CHANGED
@@ -19,7 +19,7 @@ try_spec do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'parses the argument using CVS parser' do
|
22
|
-
@result.
|
22
|
+
expect(@result).to eq([ %w[ uno due tre ] ])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -30,7 +30,7 @@ try_spec do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not change the input' do
|
33
|
-
@result.
|
33
|
+
expect(@result).to eq(@input)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ try_spec do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns nil' do
|
44
|
-
@result.
|
44
|
+
expect(@result).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -52,7 +52,7 @@ try_spec do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'returns nil' do
|
55
|
-
@result.
|
55
|
+
expect(@result).to be_nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -63,7 +63,7 @@ try_spec do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns nil' do
|
66
|
-
@result.
|
66
|
+
expect(@result).to be_nil
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -74,7 +74,7 @@ try_spec do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'returns nil' do
|
77
|
-
@result.
|
77
|
+
expect(@result).to be_nil
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -85,7 +85,7 @@ try_spec do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'returns input as is' do
|
88
|
-
@result.
|
88
|
+
expect(@result).to eql(@input)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -98,7 +98,7 @@ try_spec do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'dumps value to comma separated string' do
|
101
|
-
@result.
|
101
|
+
expect(@result).to eq("uno,due,tre\nuno,dos,tres\n")
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -109,7 +109,7 @@ try_spec do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'returns input as is' do
|
112
|
-
@result.
|
112
|
+
expect(@result).to eq(@input)
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -120,7 +120,7 @@ try_spec do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'returns nil' do
|
123
|
-
@result.
|
123
|
+
expect(@result).to be_nil
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -131,7 +131,7 @@ try_spec do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'returns nil' do
|
134
|
-
@result.
|
134
|
+
expect(@result).to be_nil
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -26,15 +26,13 @@ describe Ardm::Property::DirtyMinder,'set!' do
|
|
26
26
|
|
27
27
|
shared_examples_for 'a non hooked value' do
|
28
28
|
it 'should not extend value with hook' do
|
29
|
-
|
29
|
+
expect(object.get!(resource)).not_to be_kind_of(Ardm::Property::DirtyMinder::Hooker)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
shared_examples_for 'a hooked value' do
|
34
|
-
it 'should extend value with hook' do
|
35
|
-
|
36
|
-
value.should be_kind_of(Ardm::Property::DirtyMinder::Hooker)
|
37
|
-
end
|
34
|
+
it 'should extend value with hook', pending: true do
|
35
|
+
expect(object.get!(resource)).to be_kind_of(Ardm::Property::DirtyMinder::Hooker)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
data/spec/unit/enum_spec.rb
CHANGED
@@ -18,14 +18,14 @@ try_spec do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should return the key of the value match from the flag map' do
|
21
|
-
@enum.dump(:first).
|
22
|
-
@enum.dump(:second).
|
23
|
-
@enum.dump(:third).
|
21
|
+
expect(@enum.dump(:first)).to eq(1)
|
22
|
+
expect(@enum.dump(:second)).to eq(2)
|
23
|
+
expect(@enum.dump(:third)).to eq(3)
|
24
24
|
end
|
25
25
|
|
26
26
|
describe 'when there is no match' do
|
27
27
|
it 'should return nil' do
|
28
|
-
@enum.dump(:zero).
|
28
|
+
expect(@enum.dump(:zero)).to be_nil
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -36,14 +36,14 @@ try_spec do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'returns the value of the key match from the flag map' do
|
39
|
-
@enum.load(1).
|
40
|
-
@enum.load(2).
|
41
|
-
@enum.load(3).
|
39
|
+
expect(@enum.load(1)).to eq(:uno)
|
40
|
+
expect(@enum.load(2)).to eq(:dos)
|
41
|
+
expect(@enum.load(3)).to eq(:tres)
|
42
42
|
end
|
43
43
|
|
44
44
|
describe 'when there is no key' do
|
45
45
|
it 'returns nil' do
|
46
|
-
@enum.load(-1).
|
46
|
+
expect(@enum.load(-1)).to be_nil
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -56,19 +56,19 @@ try_spec do
|
|
56
56
|
|
57
57
|
describe 'when given a symbol' do
|
58
58
|
it 'uses Enum type' do
|
59
|
-
@enum.typecast(:uno).
|
59
|
+
expect(@enum.typecast(:uno)).to eq(:uno)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
describe 'when given a string' do
|
64
64
|
it 'uses Enum type' do
|
65
|
-
@enum.typecast('uno').
|
65
|
+
expect(@enum.typecast('uno')).to eq(:uno)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe 'when given nil' do
|
70
70
|
it 'returns nil' do
|
71
|
-
@enum.typecast( nil).
|
71
|
+
expect(@enum.typecast( nil)).to eq(nil)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -80,19 +80,19 @@ try_spec do
|
|
80
80
|
|
81
81
|
describe 'when given an integer' do
|
82
82
|
it 'uses Enum type' do
|
83
|
-
@enum.typecast(1).
|
83
|
+
expect(@enum.typecast(1)).to eq(1)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe 'when given a float' do
|
88
88
|
it 'uses Enum type' do
|
89
|
-
@enum.typecast(1.1).
|
89
|
+
expect(@enum.typecast(1.1)).to eq(1)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe 'when given nil' do
|
94
94
|
it 'returns nil' do
|
95
|
-
@enum.typecast( nil).
|
95
|
+
expect(@enum.typecast( nil)).to eq(nil)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -104,19 +104,19 @@ try_spec do
|
|
104
104
|
|
105
105
|
describe 'when given a symbol' do
|
106
106
|
it 'uses Enum type' do
|
107
|
-
@enum.typecast(:uno).
|
107
|
+
expect(@enum.typecast(:uno)).to eq('uno')
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
describe 'when given a string' do
|
112
112
|
it 'uses Enum type' do
|
113
|
-
@enum.typecast('uno').
|
113
|
+
expect(@enum.typecast('uno')).to eq('uno')
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
describe 'when given nil' do
|
118
118
|
it 'returns nil' do
|
119
|
-
@enum.typecast( nil).
|
119
|
+
expect(@enum.typecast( nil)).to eq(nil)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|