datamappify 0.50.0 → 0.51.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +78 -4
  4. data/lib/datamappify/data/criteria/active_record/find_multiple.rb +28 -0
  5. data/lib/datamappify/data/criteria/common.rb +28 -8
  6. data/lib/datamappify/data/criteria/relational/find_multiple.rb +62 -3
  7. data/lib/datamappify/data/criteria/sequel/find_multiple.rb +31 -0
  8. data/lib/datamappify/data/errors.rb +3 -0
  9. data/lib/datamappify/data/mapper/attribute.rb +81 -3
  10. data/lib/datamappify/data/mapper.rb +12 -12
  11. data/lib/datamappify/data/provider/active_record.rb +20 -5
  12. data/lib/datamappify/data/provider/common_provider.rb +2 -0
  13. data/lib/datamappify/data/provider/sequel.rb +25 -6
  14. data/lib/datamappify/data/record.rb +18 -5
  15. data/lib/datamappify/entity/composable.rb +63 -7
  16. data/lib/datamappify/entity/relation.rb +1 -1
  17. data/lib/datamappify/repository/inheritable.rb +28 -0
  18. data/lib/datamappify/repository/query_method/find_multiple.rb +1 -7
  19. data/lib/datamappify/repository/query_method/method.rb +2 -2
  20. data/lib/datamappify/repository/query_methods.rb +8 -4
  21. data/lib/datamappify/repository.rb +2 -0
  22. data/lib/datamappify/version.rb +1 -1
  23. data/spec/entity/composable_spec.rb +34 -11
  24. data/spec/entity/inheritance_spec.rb +33 -0
  25. data/spec/entity/relation_spec.rb +11 -9
  26. data/spec/repository/finders_spec.rb +185 -7
  27. data/spec/support/entities/admin_user.rb +5 -0
  28. data/spec/support/entities/computer.rb +2 -0
  29. data/spec/support/entities/computer_hardware.rb +4 -0
  30. data/spec/support/entities/computer_software.rb +3 -0
  31. data/spec/support/repositories/active_record/admin_user_repository.rb +5 -0
  32. data/spec/support/repositories/sequel/admin_user_repository.rb +5 -0
  33. data/spec/support/tables/active_record.rb +1 -0
  34. data/spec/support/tables/sequel.rb +1 -0
  35. data/spec/unit/entity/relation_spec.rb +12 -2
  36. metadata +11 -2
@@ -12,14 +12,69 @@ module Datamappify
12
12
  #
13
13
  # @return [void]
14
14
  def attributes_from(entity_class, options = {})
15
- entity_class.attribute_set.each do |attribute|
15
+ setup_attributes(entity_class, options)
16
+ setup_validators(entity_class, options)
17
+ run_validators
18
+ end
19
+
20
+ private
21
+
22
+ # @param (see #attributes_from)
23
+ #
24
+ # @return (see #attributes_from)
25
+ def setup_attributes(entity_class, options)
26
+ entity_class.attribute_set.dup.each do |attribute|
16
27
  unless excluded_attributes(entity_class).include?(attribute.name)
17
- self.attribute_set << tweak_attribute!(attribute, options)
28
+ self.attribute_set << tweak_attribute(attribute, options)
18
29
  end
19
30
  end
20
31
  end
21
32
 
22
- private
33
+ # @param (see #attributes_from)
34
+ #
35
+ # @return (see #attributes_from)
36
+ def setup_validators(entity_class, options)
37
+ if options[:prefix_with]
38
+ rename_validators(entity_class, options[:prefix_with])
39
+ else
40
+ entity_class._validators.each { |k, v| self._validators[k] = v.dup }
41
+ end
42
+ end
43
+
44
+ # @return [void]
45
+ def run_validators
46
+ self._validators.each do |_, validators|
47
+ validators.each do |validator|
48
+ validate(validator, validator.options)
49
+ end
50
+ end
51
+ end
52
+
53
+ # @param entity_class [Entity]
54
+ #
55
+ # @param prefix [Symbol]
56
+ #
57
+ # @return [void]
58
+ def rename_validators(entity_class, prefix)
59
+ entity_class._validators.each do |attribute_name, validators|
60
+ dup_validators = validators.dup
61
+
62
+ dup_validators.each do |validator|
63
+ rename_validator_attributes(validator, prefix)
64
+ end
65
+
66
+ self._validators[:"#{prefix}_#{attribute_name}"] = dup_validators
67
+ end
68
+ end
69
+
70
+ # @param validator [Validator]
71
+ #
72
+ # @param prefix (see #rename_validators)
73
+ #
74
+ # @return [void]
75
+ def rename_validator_attributes(validator, prefix)
76
+ validator.instance_variable_set :@attributes, validator.attributes.map { |name| :"#{prefix}_#{name}" }
77
+ end
23
78
 
24
79
  # @param entity_class [Entity]
25
80
  #
@@ -33,8 +88,8 @@ module Datamappify
33
88
  # @param options [Hash]
34
89
  #
35
90
  # @return [Virtus::Attribute]
36
- def tweak_attribute!(attribute, options)
37
- prefix_attribute_name!(attribute, options[:prefix_with]) if options[:prefix_with]
91
+ def tweak_attribute(attribute, options)
92
+ prefix_attribute_name(attribute, options[:prefix_with]) if options[:prefix_with]
38
93
 
39
94
  attribute
40
95
  end
@@ -44,8 +99,9 @@ module Datamappify
44
99
  # @param prefix [Symbol]
45
100
  #
46
101
  # @return [void]
47
- def prefix_attribute_name!(attribute, prefix)
48
- attribute.instance_variable_set :@name, :"#{prefix}_#{attribute.name}"
102
+ def prefix_attribute_name(attribute, prefix)
103
+ name = attribute.instance_variable_set :@name, :"#{prefix}_#{attribute.name}"
104
+ attribute.instance_variable_set :@instance_variable_name, "@#{name}".to_sym
49
105
  end
50
106
  end
51
107
  end
@@ -33,7 +33,7 @@ module Datamappify
33
33
 
34
34
  def #{entity_name}=(entity)
35
35
  @#{entity_name} = entity
36
- self.#{entity_name}_id = entity.id
36
+ self.#{entity_name}_id = entity.nil? ? nil : entity.id
37
37
  end
38
38
  CODE
39
39
  end
@@ -0,0 +1,28 @@
1
+ module Datamappify
2
+ module Repository
3
+ module Inheritable
4
+ # @param klass [Repository]
5
+ #
6
+ # @return [void]
7
+ def inherited(klass)
8
+ klass.class_eval { include Repository }
9
+
10
+ setup_data_mapper(klass)
11
+
12
+ klass.data_mapper.default_source_class
13
+ end
14
+
15
+ private
16
+
17
+ # @param klass (see #inherited)
18
+ #
19
+ # @return [void]
20
+ def setup_data_mapper(klass)
21
+ klass.for_entity self.data_mapper.entity_class
22
+ klass.default_provider self.data_mapper.default_provider_name
23
+
24
+ klass.data_mapper.custom_mapping = self.data_mapper.custom_mapping.dup
25
+ end
26
+ end
27
+ end
28
+ end
@@ -14,7 +14,7 @@ module Datamappify
14
14
  # @return [Array<Entity>]
15
15
  def perform
16
16
  dispatch_criteria_to_default_source(
17
- :FindMultiple, data_mapper.entity_class, @criteria, attributes
17
+ :FindMultiple, data_mapper.entity_class, @criteria, data_mapper.attributes
18
18
  )
19
19
  end
20
20
 
@@ -22,12 +22,6 @@ module Datamappify
22
22
  def reader?
23
23
  true
24
24
  end
25
-
26
- private
27
-
28
- def attributes
29
- data_mapper.attributes_from_default_source
30
- end
31
25
  end
32
26
  end
33
27
  end
@@ -73,10 +73,10 @@ module Datamappify
73
73
  # @param entity [Entity]
74
74
  #
75
75
  # @return [void]
76
- def dispatch_criteria_to_providers(criteria_name, entity)
76
+ def dispatch_criteria_to_providers(criteria_name, entity, *args)
77
77
  attributes_walker(entity) do |provider_name, source_class, attributes|
78
78
  data_mapper.provider(provider_name).build_criteria(
79
- criteria_name, source_class, entity, attributes
79
+ criteria_name, source_class, entity, attributes, *args
80
80
  )
81
81
  end
82
82
  end
@@ -20,12 +20,16 @@ module Datamappify
20
20
  QueryMethod::Exists.new(query_options, entity).perform
21
21
  end
22
22
 
23
- # @param id [Integer]
24
- # an entity id or a collection of entity ids
23
+ # @param criteria [Integer, Hash]
24
+ # an entity id or a hash containing criteria
25
25
  #
26
26
  # @return [Entity, nil]
27
- def find(id)
28
- QueryMethod::Find.new(query_options, id).perform
27
+ def find(criteria)
28
+ if criteria.is_a?(Integer)
29
+ QueryMethod::Find.new(query_options, criteria).perform
30
+ else
31
+ QueryMethod::FindMultiple.new(query_options, criteria).perform
32
+ end
29
33
  end
30
34
 
31
35
  # Returns a collection of all the entities in the repository
@@ -2,6 +2,7 @@ require 'datamappify/repository/lazy_checking'
2
2
  require 'datamappify/repository/mapping_dsl'
3
3
  require 'datamappify/repository/unit_of_work'
4
4
  require 'datamappify/repository/query_methods'
5
+ require 'datamappify/repository/inheritable'
5
6
  require 'datamappify/data'
6
7
 
7
8
  module Datamappify
@@ -22,6 +23,7 @@ module Datamappify
22
23
  include LazyChecking
23
24
  extend MappingDSL
24
25
  include QueryMethods
26
+ extend Inheritable
25
27
  end
26
28
  end
27
29
 
@@ -1,3 +1,3 @@
1
1
  module Datamappify
2
- VERSION = '0.50.0'
2
+ VERSION = '0.51.0'
3
3
  end
@@ -1,25 +1,48 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Datamappify::Entity do
4
- subject { Computer.new }
5
-
6
- before do
7
- subject.cpu = '286'
8
- subject.ram = 8192
9
- subject.hdd = 65536
10
- subject.gfx = 'Voodoo'
11
- subject.software_os = 'OS X'
12
- subject.software_osx_id = 1
13
- subject.software_windows_id = 2
14
- subject.software_linux_id = 3
4
+ subject do
5
+ Computer.new({
6
+ :brand => 'Fruit',
7
+ :cpu => '286',
8
+ :ram => 8192,
9
+ :hdd => 65536,
10
+ :gfx => 'Voodoo',
11
+ :vendor => 'Compaq',
12
+ :software_os => 'OS X',
13
+ :software_osx_id => 1,
14
+ :software_windows_id => 2,
15
+ :software_linux_id => 3,
16
+ :software_vendor => 'Lotus'
17
+ })
15
18
  end
16
19
 
17
20
  its(:cpu) { should == '286' }
18
21
  its(:ram) { should == 8192 }
19
22
  its(:hdd) { should == 65536 }
20
23
  its(:gfx) { should == 'Voodoo' }
24
+ its(:vendor) { should == 'Compaq' }
21
25
  its(:software_os) { should == 'OS X' }
22
26
  its(:software_osx_id) { should == 1 }
23
27
  its(:software_windows_id) { should == 2 }
24
28
  its(:software_linux_id) { should == 3 }
29
+ its(:software_vendor) { should == 'Lotus' }
30
+
31
+ describe "validation" do
32
+ context "valid" do
33
+ it { should be_valid }
34
+ end
35
+
36
+ context "invalid" do
37
+ after do
38
+ subject.should be_invalid
39
+ end
40
+
41
+ it('brand') { subject.brand = nil }
42
+ it('ram') { subject.ram = 42 }
43
+ it('hdd') { subject.hdd = 42 }
44
+ it('hdd') { subject.hdd = 65537 }
45
+ it('software_os') { subject.software_os = nil }
46
+ end
47
+ end
25
48
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for "entity inheritance" do |data_provider|
4
+ context "#{data_provider}" do
5
+ let!(:admin_user_repository) { "AdminUserRepository#{data_provider}".constantize }
6
+ let(:admin_user) { admin_user_repository.save!(AdminUser.new(:first_name => 'Batman', :driver_license => 'ARKHAMCITY', :level => 42)) }
7
+
8
+ describe "persistence" do
9
+ subject { admin_user }
10
+
11
+ it_behaves_like "entity inheritance attributes"
12
+ end
13
+
14
+ describe "finder" do
15
+ subject { admin_user_repository.find(admin_user.id) }
16
+
17
+ it_behaves_like "entity inheritance attributes"
18
+ end
19
+ end
20
+ end
21
+
22
+ shared_examples_for "entity inheritance attributes" do
23
+ its(:id) { should be_kind_of(Integer) }
24
+ its(:first_name) { should == 'Batman' }
25
+ its(:driver_license) { should == 'ARKHAMCITY' }
26
+ its(:level) { should == 42 }
27
+ end
28
+
29
+ describe Datamappify::Entity do
30
+ DATA_PROVIDERS.each do |data_provider|
31
+ it_behaves_like "entity inheritance", data_provider
32
+ end
33
+ end
@@ -1,19 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  shared_examples_for "entity relations" do |data_provider|
4
- include_context "user repository", data_provider
4
+ context "#{data_provider}" do
5
+ include_context "user repository", data_provider
5
6
 
6
- let!(:comment_repository) { "CommentRepository#{data_provider}".constantize }
7
- let(:comment) { comment_repository.save!(Comment.new) }
7
+ let!(:comment_repository) { "CommentRepository#{data_provider}".constantize }
8
+ let(:comment) { comment_repository.save!(Comment.new) }
8
9
 
9
- subject { comment }
10
+ subject { comment }
10
11
 
11
- before do
12
- subject.user = existing_user
13
- end
12
+ before do
13
+ subject.user = existing_user
14
+ end
14
15
 
15
- its(:user_id) { should == existing_user.id }
16
- its(:user) { should == existing_user }
16
+ its(:user_id) { should == existing_user.id }
17
+ its(:user) { should == existing_user }
18
+ end
17
19
  end
18
20
 
19
21
  describe Datamappify::Entity do
@@ -7,17 +7,115 @@ shared_examples_for "finders" do |data_provider|
7
7
  let!(:existing_user_2) { user_repository.save(new_valid_user.dup) }
8
8
 
9
9
  context "#{data_provider}" do
10
- describe "#all" do
11
- it "finds all entities in a repository" do
12
- user_repository.all.should have(3).users
10
+ describe "#find" do
11
+ describe "by id" do
12
+ subject { user_repository.find(existing_user.id) }
13
+
14
+ its(:id) { should == existing_user.id }
13
15
  end
14
16
 
15
- it "finds first entity" do
16
- user_repository.all.first.should == existing_user
17
+ describe "by criteria" do
18
+ before do
19
+ user_repository.save!(User.new(:first_name => 'Mary', :driver_license => 'IDONTCARE'))
20
+ user_repository.save!(User.new(:first_name => 'Bob', :driver_license => 'IDONTCARE'))
21
+ user_repository.save!(User.new(:first_name => 'Jane', :driver_license => 'NO_LICENSE'))
22
+ user_repository.save!(User.new(:first_name => 'Bob', :driver_license => 'NO_LICENSE'))
23
+ user_repository.save!(User.new(:first_name => 'Bob', :driver_license => 'IDONTCARE'))
24
+ user_repository.save!(User.new(:first_name => 'Bobb', :driver_license => 'IDONTCARE'))
25
+ user_repository.save!(User.new(:first_name => 'John', :driver_license => 'IDONTCARE'))
26
+ end
27
+
28
+ describe "by attribute that does not exist" do
29
+ let(:records) { user_repository.find(:blah => 'Bob') }
30
+
31
+ it { expect { records }.to raise_exception(Datamappify::Data::EntityAttributeInvalid) }
32
+ end
33
+
34
+ describe "by primary attribute" do
35
+ let(:records) { user_repository.find(:first_name => 'Bob') }
36
+ subject { records }
37
+
38
+ it { should have(3).users }
39
+
40
+ describe "record" do
41
+ subject { records.first }
42
+
43
+ its(:first_name) { should == 'Bob' }
44
+ its(:driver_license) { should == 'IDONTCARE' }
45
+ end
46
+ end
47
+
48
+ describe "by secondary attribute" do
49
+ let(:records) { user_repository.find(:driver_license => 'NO_LICENSE') }
50
+ subject { records }
51
+
52
+ it { should have(2).user }
53
+
54
+ describe "record" do
55
+ subject { records.first }
56
+
57
+ its(:first_name) { should == 'Jane' }
58
+ its(:driver_license) { should == 'NO_LICENSE' }
59
+ end
60
+ end
61
+
62
+ describe "by primary and secondary attributes" do
63
+ context "example 1" do
64
+ let(:records) { user_repository.find(:first_name => 'Bob', :driver_license => 'NO_LICENSE') }
65
+ subject { records }
66
+
67
+ it { should have(1).user }
68
+
69
+ describe "record" do
70
+ subject { records.first }
71
+
72
+ its(:first_name) { should == 'Bob' }
73
+ its(:driver_license) { should == 'NO_LICENSE' }
74
+ end
75
+ end
76
+
77
+ context "example 2" do
78
+ let(:records) { user_repository.find(:first_name => 'Bob', :driver_license => 'IDONTCARE') }
79
+ subject { records }
80
+
81
+ it { should have(2).users }
82
+
83
+ describe "record" do
84
+ subject { records.first }
85
+
86
+ its(:first_name) { should == 'Bob' }
87
+ its(:driver_license) { should == 'IDONTCARE' }
88
+ end
89
+ end
90
+
91
+ context "example 3" do
92
+ subject { user_repository.find(:first_name => 'Nope', :driver_license => 'IDONTCARE') }
93
+
94
+ it { should be_empty }
95
+ end
96
+
97
+ context "example 4" do
98
+ subject { user_repository.find(:first_name => 'Bob', :driver_license => 'NOPE') }
99
+
100
+ it { should be_empty }
101
+ end
102
+ end
17
103
  end
104
+ end
105
+
106
+ describe "#all" do
107
+ let(:records) { user_repository.all }
108
+ subject { records }
109
+
110
+ it { should have(3).users }
18
111
 
19
- it "finds last entity" do
20
- user_repository.all.last.should == existing_user_2
112
+ its(:first) { should == existing_user }
113
+ its(:last) { should == existing_user_2 }
114
+
115
+ describe "record" do
116
+ subject { records.first }
117
+
118
+ its(:first_name) { should == existing_user.first_name }
21
119
  end
22
120
  end
23
121
  end
@@ -28,3 +126,83 @@ describe Datamappify::Repository do
28
126
  it_behaves_like "finders", data_provider
29
127
  end
30
128
  end
129
+
130
+ describe "attributes from different data providers" do
131
+ before do
132
+ pending
133
+
134
+ HeroUserRepository.save!(HeroUser.new(:first_name => 'Fred', :last_name => 'Wu'))
135
+ HeroUserRepository.save!(HeroUser.new(:first_name => 'Sheldon', :last_name => 'Cooper'))
136
+ HeroUserRepository.save!(HeroUser.new(:first_name => 'Fred', :last_name => 'Cooper'))
137
+ end
138
+
139
+ context "example 1" do
140
+ let(:records) { HeroUserRepository.find(:first_name => 'Fred') }
141
+ subject { records }
142
+
143
+ it { should have(2).users }
144
+
145
+ describe "record" do
146
+ subject { records.first }
147
+
148
+ its(:first_name) { should == 'Fred' }
149
+ its(:last_name) { should == 'Wu' }
150
+ end
151
+ end
152
+
153
+ context "example 2" do
154
+ let(:records) { HeroUserRepository.find(:first_name => 'Sheldon') }
155
+ subject { records }
156
+
157
+ it { should have(1).user }
158
+
159
+ describe "record" do
160
+ subject { records.first }
161
+
162
+ its(:first_name) { should == 'Sheldon' }
163
+ its(:last_name) { should == 'Cooper' }
164
+ end
165
+ end
166
+
167
+ context "example 3" do
168
+ let(:records) { HeroUserRepository.find(:last_name => 'Cooper') }
169
+ subject { records }
170
+
171
+ it { should have(2).users }
172
+
173
+ describe "record" do
174
+ subject { records.first }
175
+
176
+ its(:first_name) { should == 'Sheldon' }
177
+ its(:last_name) { should == 'Cooper' }
178
+ end
179
+ end
180
+
181
+ context "example 4" do
182
+ let(:records) { HeroUserRepository.find(:first_name => 'Sheldon', :last_name => 'Cooper') }
183
+ subject { records }
184
+
185
+ it { should have(1).user }
186
+
187
+ describe "record" do
188
+ subject { records.first }
189
+
190
+ its(:first_name) { should == 'Sheldon' }
191
+ its(:last_name) { should == 'Cooper' }
192
+ end
193
+ end
194
+
195
+ context "example 5" do
196
+ let(:records) { HeroUserRepository.find(:first_name => 'Leonard', :last_name => 'Cooper') }
197
+ subject { records }
198
+
199
+ it { should be_empty }
200
+ end
201
+
202
+ context "example 6" do
203
+ let(:records) { HeroUserRepository.find(:first_name => 'Fred', :last_name => 'Woo') }
204
+ subject { records }
205
+
206
+ it { should be_empty }
207
+ end
208
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'user'
2
+
3
+ class AdminUser < User
4
+ attribute :level, Integer
5
+ end
@@ -8,4 +8,6 @@ class Computer
8
8
 
9
9
  attributes_from ComputerHardware
10
10
  attributes_from ComputerSoftware, :prefix_with => :software
11
+
12
+ validates :brand, :presence => true
11
13
  end
@@ -5,4 +5,8 @@ class ComputerHardware
5
5
  attribute :ram, Integer
6
6
  attribute :hdd, Integer
7
7
  attribute :gfx, String
8
+ attribute :vendor, String
9
+
10
+ validates :ram, :hdd, :numericality => { :greater_than_or_equal_to => 4096 }
11
+ validates :hdd, :numericality => { :less_than_or_equal_to => 65536 }
8
12
  end
@@ -2,8 +2,11 @@ class ComputerSoftware
2
2
  include Datamappify::Entity
3
3
 
4
4
  attribute :os, String
5
+ attribute :vendor, String
5
6
 
6
7
  references :osx
7
8
  references :windows
8
9
  references :linux
10
+
11
+ validates_presence_of :os
9
12
  end
@@ -0,0 +1,5 @@
1
+ require_relative 'user_repository'
2
+
3
+ class AdminUserRepositoryActiveRecord < UserRepositoryActiveRecord
4
+ for_entity AdminUser
5
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'user_repository'
2
+
3
+ class AdminUserRepositorySequel < UserRepositorySequel
4
+ for_entity AdminUser
5
+ end
@@ -17,6 +17,7 @@ ActiveRecord::Migration.suppress_messages do
17
17
  t.string :first_name, :null => false
18
18
  t.string :surname
19
19
  t.integer :age
20
+ t.integer :level
20
21
  t.references :role
21
22
  t.timestamps
22
23
  end
@@ -16,6 +16,7 @@ DB.create_table :users do
16
16
  String :first_name, :null => false
17
17
  String :surname
18
18
  Integer :age
19
+ Integer :level
19
20
  foreign_key :role_id
20
21
  DateTime :created_at
21
22
  DateTime :updated_at
@@ -15,14 +15,14 @@ module Datamappify::Entity
15
15
  subject { DummyEntity.new }
16
16
 
17
17
  describe "#references" do
18
+ let(:another_entity) { AnotherEntity.new.tap { |e| e.id = 42 } }
19
+
18
20
  it { should respond_to(:another_entity_id) }
19
21
  it { should respond_to(:another_entity_id=) }
20
22
  it { should respond_to(:another_entity) }
21
23
  it { should respond_to(:another_entity=) }
22
24
 
23
25
  describe "assigns the correct attribute" do
24
- let(:another_entity) { AnotherEntity.new.tap { |e| e.id = 42 } }
25
-
26
26
  before do
27
27
  subject.another_entity = another_entity
28
28
  end
@@ -31,6 +31,16 @@ module Datamappify::Entity
31
31
  its(:another_entity) { should == another_entity }
32
32
  its(:reference_keys) { should include(:another_entity_id) }
33
33
  end
34
+
35
+ describe "assigns nil" do
36
+ before do
37
+ subject.another_entity = nil
38
+ end
39
+
40
+ its(:another_entity_id) { should be_nil }
41
+ its(:another_entity) { should be_nil }
42
+ its(:reference_keys) { should include(:another_entity_id) }
43
+ end
34
44
  end
35
45
  end
36
46
  end