active_type 0.4.4 → 0.4.5

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -1
  4. data/README.md +4 -4
  5. data/gemfiles/Gemfile.3.2.mysql2 +1 -1
  6. data/gemfiles/Gemfile.3.2.mysql2.lock +16 -11
  7. data/gemfiles/Gemfile.3.2.sqlite3 +1 -1
  8. data/gemfiles/Gemfile.3.2.sqlite3.lock +16 -11
  9. data/gemfiles/Gemfile.4.0.sqlite3 +1 -1
  10. data/gemfiles/Gemfile.4.0.sqlite3.lock +16 -11
  11. data/gemfiles/Gemfile.4.1.sqlite3 +1 -1
  12. data/gemfiles/Gemfile.4.1.sqlite3.lock +16 -11
  13. data/gemfiles/Gemfile.4.2.1.mysql2 +1 -1
  14. data/gemfiles/Gemfile.4.2.1.mysql2.lock +16 -11
  15. data/gemfiles/Gemfile.4.2.1.pg +1 -1
  16. data/gemfiles/Gemfile.4.2.1.pg.lock +16 -11
  17. data/gemfiles/Gemfile.4.2.1.sqlite3 +1 -1
  18. data/gemfiles/Gemfile.4.2.1.sqlite3.lock +16 -11
  19. data/lib/active_type/version.rb +1 -1
  20. data/lib/active_type/virtual_attributes.rb +1 -1
  21. data/spec/active_type/extended_record/single_table_inheritance_spec.rb +6 -6
  22. data/spec/active_type/extended_record_spec.rb +32 -26
  23. data/spec/active_type/nested_attributes_spec.rb +51 -51
  24. data/spec/active_type/object_spec.rb +44 -33
  25. data/spec/active_type/record_spec.rb +15 -11
  26. data/spec/active_type/util_spec.rb +25 -25
  27. data/spec/integration/holidays_spec.rb +13 -13
  28. data/spec/integration/shape_spec.rb +12 -14
  29. data/spec/integration/sign_in_spec.rb +12 -12
  30. data/spec/integration/sign_up_spec.rb +9 -9
  31. data/spec/shared_examples/accessors.rb +3 -3
  32. data/spec/shared_examples/belongs_to.rb +2 -2
  33. data/spec/shared_examples/coercible_columns.rb +27 -27
  34. data/spec/shared_examples/constructor.rb +2 -2
  35. data/spec/shared_examples/defaults.rb +10 -10
  36. data/spec/shared_examples/dirty_tracking.rb +4 -4
  37. data/spec/shared_examples/dupable.rb +4 -4
  38. data/spec/shared_examples/mass_assignment.rb +1 -1
  39. metadata +2 -2
@@ -40,7 +40,7 @@ describe SignUpSpec::User do
40
40
  subject.email = "email"
41
41
  subject.password = "password"
42
42
 
43
- subject.should be_valid
43
+ expect(subject).to be_valid
44
44
  end
45
45
 
46
46
  end
@@ -52,26 +52,26 @@ describe SignUpSpec::SignUp do
52
52
  subject.password = "password"
53
53
  subject.terms = true
54
54
 
55
- subject.should_not be_valid
56
- subject.errors['email'].should == ["can't be blank"]
55
+ expect(subject).not_to be_valid
56
+ expect(subject.errors['email']).to eq(["can't be blank"])
57
57
  end
58
58
 
59
59
  it 'is invalid without accepted terms' do
60
60
  subject.email = "email"
61
61
  subject.password = "password"
62
62
 
63
- subject.should_not be_valid
64
- subject.errors['terms'].should == ["must be accepted"]
63
+ expect(subject).not_to be_valid
64
+ expect(subject.errors['terms']).to eq(["must be accepted"])
65
65
  end
66
66
 
67
67
  context 'with invalid data' do
68
68
 
69
69
  it 'does not save' do
70
- subject.save.should be_false
70
+ expect(subject.save).to be_falsey
71
71
  end
72
72
 
73
73
  it 'does not send an email' do
74
- subject.should_not_receive :send_welcome_email
74
+ expect(subject).not_to receive :send_welcome_email
75
75
  subject.save
76
76
  end
77
77
 
@@ -87,11 +87,11 @@ describe SignUpSpec::SignUp do
87
87
 
88
88
  it 'does save' do
89
89
  subject.valid?
90
- subject.save.should be_true
90
+ expect(subject.save).to eq(true)
91
91
  end
92
92
 
93
93
  it 'sends the email' do
94
- subject.should_receive :send_welcome_email
94
+ expect(subject).to receive :send_welcome_email
95
95
 
96
96
  subject.save
97
97
  end
@@ -20,21 +20,21 @@ shared_examples_for "ActiveRecord-like accessors" do |attributes|
20
20
  it 'allows to read and write' do
21
21
  attributes.each do |key, value|
22
22
  subject.send("#{key}=", value)
23
- subject.send(key).should == value
23
+ expect(subject.send(key)).to eq(value)
24
24
  end
25
25
  end
26
26
 
27
27
  it 'allows to read via []' do
28
28
  attributes.each do |key, value|
29
29
  subject.send("#{key}=", value)
30
- subject[key].should == value
30
+ expect(subject[key]).to eq(value)
31
31
  end
32
32
  end
33
33
 
34
34
  it 'allows to write via []=' do
35
35
  attributes.each do |key, value|
36
36
  subject[key] = value
37
- subject.send(key).should == value
37
+ expect(subject.send(key)).to eq(value)
38
38
  end
39
39
  end
40
40
 
@@ -5,13 +5,13 @@ shared_examples_for 'a belongs_to association' do |association, klass|
5
5
  it 'sets the id when assigning a record' do
6
6
  subject.send("#{association}=", record)
7
7
 
8
- subject.send("#{association}_id").should == record.id
8
+ expect(subject.send("#{association}_id")).to eq(record.id)
9
9
  end
10
10
 
11
11
  it 'sets the record when assigning an id' do
12
12
  subject.send("#{association}_id=", record.id)
13
13
 
14
- subject.send("#{association}").should == record
14
+ expect(subject.send("#{association}")).to eq(record)
15
15
  end
16
16
 
17
17
  end
@@ -6,19 +6,19 @@ end
6
6
  shared_examples_for 'a coercible string column' do |column|
7
7
 
8
8
  it 'is nil by default' do
9
- subject.send(column).should be_nil
9
+ expect(subject.send(column)).to be_nil
10
10
  end
11
11
 
12
12
  it 'leaves strings alone' do
13
13
  subject.send(:"#{column}=", "string")
14
14
 
15
- subject.send(column).should == "string"
15
+ expect(subject.send(column)).to eq("string")
16
16
  end
17
17
 
18
18
  it 'does not convert blank' do
19
19
  subject.send(:"#{column}=", "")
20
20
 
21
- subject.send(column).should == ""
21
+ expect(subject.send(column)).to eq("")
22
22
  end
23
23
 
24
24
  end
@@ -27,25 +27,25 @@ end
27
27
  shared_examples_for 'a coercible integer column' do |column|
28
28
 
29
29
  it 'is nil by default' do
30
- subject.send(column).should be_nil
30
+ expect(subject.send(column)).to be_nil
31
31
  end
32
32
 
33
33
  it 'leaves integers alone' do
34
34
  subject.send(:"#{column}=", 10)
35
35
 
36
- subject.send(column).should == 10
36
+ expect(subject.send(column)).to eq(10)
37
37
  end
38
38
 
39
39
  it 'converts strings to integers' do
40
40
  subject.send(:"#{column}=", "10")
41
41
 
42
- subject.send(column).should == 10
42
+ expect(subject.send(column)).to eq(10)
43
43
  end
44
44
 
45
45
  it 'converts blank to nil' do
46
46
  subject.send(:"#{column}=", "")
47
47
 
48
- subject.send(column).should be_nil
48
+ expect(subject.send(column)).to be_nil
49
49
  end
50
50
 
51
51
  end
@@ -54,26 +54,26 @@ end
54
54
  shared_examples_for 'a coercible date column' do |column|
55
55
 
56
56
  it 'is nil by default' do
57
- subject.send(column).should be_nil
57
+ expect(subject.send(column)).to be_nil
58
58
  end
59
59
 
60
60
  it 'leaves dates alone' do
61
61
  date = Date.today
62
62
  subject.send(:"#{column}=", date)
63
63
 
64
- subject.send(column).should == date
64
+ expect(subject.send(column)).to eq(date)
65
65
  end
66
66
 
67
67
  it 'converts strings to dates' do
68
68
  subject.send(:"#{column}=", "2010-10-01")
69
69
 
70
- subject.send(column).should == Date.new(2010, 10, 1)
70
+ expect(subject.send(column)).to eq(Date.new(2010, 10, 1))
71
71
  end
72
72
 
73
73
  it 'converts blank to nil' do
74
74
  subject.send(:"#{column}=", "")
75
75
 
76
- subject.send(column).should be_nil
76
+ expect(subject.send(column)).to be_nil
77
77
  end
78
78
 
79
79
  end
@@ -105,26 +105,26 @@ shared_examples_for 'a coercible time column' do |column|
105
105
  comparison.persisted_time = time
106
106
 
107
107
  result = subject.send(column)
108
- result.should == comparison.persisted_time
109
- result.zone.should == comparison.persisted_time.zone
108
+ expect(result).to eq(comparison.persisted_time)
109
+ expect(result.zone).to eq(comparison.persisted_time.zone)
110
110
  end
111
111
 
112
112
 
113
113
  it 'is nil by default' do
114
- subject.send(column).should be_nil
114
+ expect(subject.send(column)).to be_nil
115
115
  end
116
116
 
117
117
  it 'leaves times alone' do
118
118
  time = Time.now
119
119
  subject.send(:"#{column}=", time)
120
120
 
121
- subject.send(column).should == time
121
+ expect(subject.send(column)).to eq(time)
122
122
  end
123
123
 
124
124
  it 'converts strings to times' do
125
125
  subject.send(:"#{column}=", "2010-10-01 12:15")
126
126
 
127
- subject.send(column).should == Time.local(2010, 10, 1, 12, 15)
127
+ expect(subject.send(column)).to eq(Time.local(2010, 10, 1, 12, 15))
128
128
  end
129
129
 
130
130
  it 'behaves consistently with ActiveRecord' do
@@ -161,68 +161,68 @@ end
161
161
  shared_examples_for 'a coercible boolean column' do |column|
162
162
 
163
163
  it 'is nil by default' do
164
- subject.send(column).should be_nil
164
+ expect(subject.send(column)).to be_nil
165
165
  end
166
166
 
167
167
  it 'leaves booleans alone' do
168
168
  subject.send(:"#{column}=", true)
169
169
 
170
- subject.send(column).should == true
170
+ expect(subject.send(column)).to eq(true)
171
171
  end
172
172
 
173
173
  it 'converts 1 to true' do
174
174
  subject.send(:"#{column}=", "1")
175
175
 
176
- subject.send(column).should == true
176
+ expect(subject.send(column)).to eq(true)
177
177
  end
178
178
 
179
179
  it 'converts 0 to false' do
180
180
  subject.send(:"#{column}=", "0")
181
181
 
182
- subject.send(column).should == false
182
+ expect(subject.send(column)).to eq(false)
183
183
  end
184
184
 
185
185
  it 'converts "" to nil' do
186
186
  subject.send(:"#{column}=", "")
187
187
 
188
- subject.send(column).should be_nil
188
+ expect(subject.send(column)).to be_nil
189
189
  end
190
190
 
191
191
  it 'converts "true" to true' do
192
192
  subject.send(:"#{column}=", "true")
193
193
 
194
- subject.send(column).should == true
194
+ expect(subject.send(column)).to eq(true)
195
195
  end
196
196
 
197
197
  it 'converts "false" to false' do
198
198
  subject.send(:"#{column}=", "false")
199
199
 
200
- subject.send(column).should == false
200
+ expect(subject.send(column)).to eq(false)
201
201
  end
202
202
 
203
203
  end
204
204
 
205
205
  shared_examples_for 'an untyped column' do |column|
206
206
  it 'is nil by default' do
207
- subject.send(column).should be_nil
207
+ expect(subject.send(column)).to be_nil
208
208
  end
209
209
 
210
210
  it 'leaves strings alone' do
211
211
  subject.send(:"#{column}=", "string")
212
212
 
213
- subject.send(column).should == "string"
213
+ expect(subject.send(column)).to eq("string")
214
214
  end
215
215
 
216
216
  it 'leaves integers alone' do
217
217
  subject.send(:"#{column}=", 17)
218
218
 
219
- subject.send(column).should == 17
219
+ expect(subject.send(column)).to eq(17)
220
220
  end
221
221
 
222
222
  it 'leaves objects alone' do
223
223
  object = Object.new
224
224
  subject.send(:"#{column}=", object)
225
225
 
226
- subject.send(column).should == object
226
+ expect(subject.send(column)).to eq(object)
227
227
  end
228
228
  end
@@ -1,14 +1,14 @@
1
1
  shared_examples_for 'ActiveRecord-like constructors' do |attributes|
2
2
 
3
3
  it 'return a new record' do
4
- subject.new.should be_new_record
4
+ expect(subject.new).to be_new_record
5
5
  end
6
6
 
7
7
  it 'assigns given attributes' do
8
8
  record = subject.new(attributes)
9
9
 
10
10
  attributes.each do |key, value|
11
- record.send(key).should == value
11
+ expect(record.send(key)).to eq(value)
12
12
  end
13
13
  end
14
14
 
@@ -16,45 +16,45 @@ shared_examples_for "a class accepting attribute defaults" do |klass|
16
16
  end
17
17
 
18
18
  it 'can have static defaults' do
19
- subject.static_string.should == "static string"
19
+ expect(subject.static_string).to eq("static string")
20
20
  end
21
21
 
22
22
  it 'can have dynamic defaults' do
23
- subject.dynamic_string.should == "dynamic string"
23
+ expect(subject.dynamic_string).to eq("dynamic string")
24
24
  end
25
25
 
26
26
  it 'can have defaults refering to instance methods' do
27
- subject.referential_string.should == "value"
27
+ expect(subject.referential_string).to eq("value")
28
28
  end
29
29
 
30
30
  it 'typecasts defaults' do
31
- subject.number.should == 10
31
+ expect(subject.number).to eq(10)
32
32
  end
33
33
 
34
34
  it 'computes defaults lazily' do
35
- subject.should_receive(:compute).and_return("computed")
36
- subject.computed.should == "computed"
35
+ expect(subject).to receive(:compute).and_return("computed")
36
+ expect(subject.computed).to eq("computed")
37
37
  end
38
38
 
39
39
  it 'does not compute defaults more than once' do
40
- subject.should_receive(:compute).exactly(:once).and_return(nil)
40
+ expect(subject).to receive(:compute).exactly(:once).and_return(nil)
41
41
  subject.computed
42
42
  subject.computed
43
43
  end
44
44
 
45
45
  it 'does not compute defaults when overriden' do
46
46
  subject.computed = 'not computed'
47
- subject.computed.should == 'not computed'
47
+ expect(subject.computed).to eq('not computed')
48
48
  end
49
49
 
50
50
  it 'does not use defaults when overriden' do
51
51
  subject.static_string = "my string"
52
- subject.static_string.should == "my string"
52
+ expect(subject.static_string).to eq("my string")
53
53
  end
54
54
 
55
55
  it 'does not use defaults when overriden with nil' do
56
56
  subject.static_string = nil
57
- subject.static_string.should == nil
57
+ expect(subject.static_string).to eq(nil)
58
58
  end
59
59
 
60
60
  end
@@ -9,7 +9,7 @@ shared_examples_for "a class supporting dirty tracking for virtual attributes" d
9
9
  describe '#virtual_attribute_was' do
10
10
 
11
11
  it 'always returns nil, since there can be no previously saved value' do
12
- subject.virtual_attribute_was.should be_nil
12
+ expect(subject.virtual_attribute_was).to be_nil
13
13
  end
14
14
 
15
15
  end
@@ -18,12 +18,12 @@ shared_examples_for "a class supporting dirty tracking for virtual attributes" d
18
18
 
19
19
  it 'returns true if the attribute is not nil' do
20
20
  subject.virtual_attribute = 'foo'
21
- subject.virtual_attribute_changed?.should be_true
21
+ expect(subject.virtual_attribute_changed?).to eq(true)
22
22
  end
23
23
 
24
24
  it 'returns false if the attribute is nil' do
25
25
  subject.virtual_attribute = nil
26
- subject.virtual_attribute_changed?.should be_false
26
+ expect(subject.virtual_attribute_changed?).to be_falsey
27
27
  end
28
28
 
29
29
  end
@@ -31,7 +31,7 @@ shared_examples_for "a class supporting dirty tracking for virtual attributes" d
31
31
  describe '#virtual_attribute_will_change!' do
32
32
 
33
33
  it 'is implemented for compatibility with ActiveModel::Dirty, but does nothing' do
34
- subject.should respond_to(:virtual_attribute_will_change!)
34
+ expect(subject).to respond_to(:virtual_attribute_will_change!)
35
35
  expect { subject.virtual_attribute_will_change! }.to_not raise_error
36
36
  end
37
37
 
@@ -13,8 +13,8 @@ shared_examples_for "a class supporting dup for attributes" do |klass|
13
13
  duped = subject.dup
14
14
  duped.attribute = "bar"
15
15
 
16
- subject.attribute.should == "foo"
17
- duped.attribute.should == "bar"
16
+ expect(subject.attribute).to eq("foo")
17
+ expect(duped.attribute).to eq("bar")
18
18
  end
19
19
 
20
20
  it 'does a deep copy' do
@@ -22,8 +22,8 @@ shared_examples_for "a class supporting dup for attributes" do |klass|
22
22
  duped = subject.dup
23
23
  duped.attribute.merge!(:foo => "baz")
24
24
 
25
- subject.attribute.should == { :foo => "bar" }
26
- duped.attribute.should == { :foo => "baz" }
25
+ expect(subject.attribute).to eq({ :foo => "bar" })
26
+ expect(duped.attribute).to eq({ :foo => "baz" })
27
27
  end
28
28
 
29
29
  end
@@ -4,7 +4,7 @@ shared_examples_for 'ActiveRecord-like mass assignment' do |attributes|
4
4
  subject.attributes = attributes
5
5
 
6
6
  attributes.each do |key, value|
7
- subject.send(key).should == value
7
+ expect(subject.send(key)).to eq(value)
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-18 00:00:00.000000000 Z
12
+ date: 2016-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler