massive_record 0.2.1 → 0.2.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGELOG.md +58 -2
  2. data/Gemfile.lock +17 -17
  3. data/README.md +98 -41
  4. data/lib/massive_record.rb +2 -1
  5. data/lib/massive_record/adapters/thrift/hbase/hbase.rb +2425 -2154
  6. data/lib/massive_record/adapters/thrift/hbase/hbase_constants.rb +3 -3
  7. data/lib/massive_record/adapters/thrift/hbase/hbase_types.rb +195 -195
  8. data/lib/massive_record/adapters/thrift/row.rb +35 -4
  9. data/lib/massive_record/adapters/thrift/table.rb +49 -12
  10. data/lib/massive_record/orm/attribute_methods.rb +77 -5
  11. data/lib/massive_record/orm/attribute_methods/cast_numbers_on_write.rb +24 -0
  12. data/lib/massive_record/orm/attribute_methods/dirty.rb +18 -0
  13. data/lib/massive_record/orm/attribute_methods/time_zone_conversion.rb +24 -3
  14. data/lib/massive_record/orm/attribute_methods/write.rb +8 -1
  15. data/lib/massive_record/orm/base.rb +62 -8
  16. data/lib/massive_record/orm/column.rb +7 -11
  17. data/lib/massive_record/orm/default_id.rb +1 -1
  18. data/lib/massive_record/orm/embedded.rb +66 -0
  19. data/lib/massive_record/orm/errors.rb +17 -0
  20. data/lib/massive_record/orm/finders.rb +124 -71
  21. data/lib/massive_record/orm/finders/rescue_missing_table_on_find.rb +1 -1
  22. data/lib/massive_record/orm/finders/scope.rb +58 -34
  23. data/lib/massive_record/orm/id_factory.rb +22 -105
  24. data/lib/massive_record/orm/id_factory/atomic_incrementation.rb +117 -0
  25. data/lib/massive_record/orm/id_factory/timestamp.rb +60 -0
  26. data/lib/massive_record/orm/identity_map.rb +256 -0
  27. data/lib/massive_record/orm/log_subscriber.rb +18 -0
  28. data/lib/massive_record/orm/observer.rb +69 -0
  29. data/lib/massive_record/orm/persistence.rb +47 -119
  30. data/lib/massive_record/orm/persistence/operations.rb +100 -0
  31. data/lib/massive_record/orm/persistence/operations/atomic_operation.rb +71 -0
  32. data/lib/massive_record/orm/persistence/operations/destroy.rb +17 -0
  33. data/lib/massive_record/orm/persistence/operations/embedded/destroy.rb +26 -0
  34. data/lib/massive_record/orm/persistence/operations/embedded/insert.rb +27 -0
  35. data/lib/massive_record/orm/persistence/operations/embedded/operation_helpers.rb +66 -0
  36. data/lib/massive_record/orm/persistence/operations/embedded/reload.rb +39 -0
  37. data/lib/massive_record/orm/persistence/operations/embedded/update.rb +29 -0
  38. data/lib/massive_record/orm/persistence/operations/insert.rb +19 -0
  39. data/lib/massive_record/orm/persistence/operations/reload.rb +26 -0
  40. data/lib/massive_record/orm/persistence/operations/suppress.rb +15 -0
  41. data/lib/massive_record/orm/persistence/operations/table_operation_helpers.rb +106 -0
  42. data/lib/massive_record/orm/persistence/operations/update.rb +25 -0
  43. data/lib/massive_record/orm/query_instrumentation.rb +26 -49
  44. data/lib/massive_record/orm/raw_data.rb +47 -0
  45. data/lib/massive_record/orm/relations.rb +4 -0
  46. data/lib/massive_record/orm/relations/interface.rb +134 -0
  47. data/lib/massive_record/orm/relations/metadata.rb +58 -12
  48. data/lib/massive_record/orm/relations/proxy.rb +17 -12
  49. data/lib/massive_record/orm/relations/proxy/embedded_in.rb +54 -0
  50. data/lib/massive_record/orm/relations/proxy/embedded_in_polymorphic.rb +15 -0
  51. data/lib/massive_record/orm/relations/proxy/embeds_many.rb +215 -0
  52. data/lib/massive_record/orm/relations/proxy/references_many.rb +112 -88
  53. data/lib/massive_record/orm/relations/proxy/references_one.rb +1 -1
  54. data/lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb +1 -1
  55. data/lib/massive_record/orm/relations/proxy_collection.rb +84 -0
  56. data/lib/massive_record/orm/schema/column_family.rb +3 -2
  57. data/lib/massive_record/orm/schema/{column_interface.rb → embedded_interface.rb} +38 -4
  58. data/lib/massive_record/orm/schema/field.rb +2 -0
  59. data/lib/massive_record/orm/schema/table_interface.rb +19 -2
  60. data/lib/massive_record/orm/single_table_inheritance.rb +37 -2
  61. data/lib/massive_record/orm/timestamps.rb +17 -7
  62. data/lib/massive_record/orm/validations.rb +4 -0
  63. data/lib/massive_record/orm/validations/associated.rb +50 -0
  64. data/lib/massive_record/rails/railtie.rb +31 -0
  65. data/lib/massive_record/version.rb +1 -1
  66. data/lib/massive_record/wrapper/cell.rb +8 -1
  67. data/massive_record.gemspec +4 -4
  68. data/spec/adapter/thrift/atomic_increment_spec.rb +16 -0
  69. data/spec/adapter/thrift/table_find_spec.rb +14 -2
  70. data/spec/adapter/thrift/table_spec.rb +6 -6
  71. data/spec/adapter/thrift/utf8_encoding_of_id_spec.rb +71 -0
  72. data/spec/orm/cases/attribute_methods_spec.rb +215 -22
  73. data/spec/orm/cases/auto_generate_id_spec.rb +1 -1
  74. data/spec/orm/cases/change_id_spec.rb +62 -0
  75. data/spec/orm/cases/default_id_spec.rb +25 -6
  76. data/spec/orm/cases/default_values_spec.rb +6 -3
  77. data/spec/orm/cases/dirty_spec.rb +150 -102
  78. data/spec/orm/cases/embedded_spec.rb +250 -0
  79. data/spec/orm/cases/{finder_default_scope.rb → finder_default_scope_spec.rb} +4 -0
  80. data/spec/orm/cases/finder_scope_spec.rb +96 -29
  81. data/spec/orm/cases/finders_spec.rb +57 -10
  82. data/spec/orm/cases/id_factory/atomic_incrementation_spec.rb +72 -0
  83. data/spec/orm/cases/id_factory/timestamp_spec.rb +61 -0
  84. data/spec/orm/cases/identity_map/identity_map_spec.rb +357 -0
  85. data/spec/orm/cases/identity_map/middleware_spec.rb +74 -0
  86. data/spec/orm/cases/log_subscriber_spec.rb +15 -2
  87. data/spec/orm/cases/observing_spec.rb +61 -0
  88. data/spec/orm/cases/persistence_spec.rb +151 -60
  89. data/spec/orm/cases/raw_data_spec.rb +58 -0
  90. data/spec/orm/cases/single_table_inheritance_spec.rb +58 -2
  91. data/spec/orm/cases/table_spec.rb +3 -3
  92. data/spec/orm/cases/time_zone_awareness_spec.rb +27 -0
  93. data/spec/orm/cases/timestamps_spec.rb +23 -109
  94. data/spec/orm/cases/validation_spec.rb +9 -0
  95. data/spec/orm/models/address.rb +5 -1
  96. data/spec/orm/models/address_with_timestamp.rb +12 -0
  97. data/spec/orm/models/car.rb +5 -0
  98. data/spec/orm/models/person.rb +13 -1
  99. data/spec/orm/models/person_with_timestamp.rb +4 -2
  100. data/spec/orm/models/test_class.rb +1 -0
  101. data/spec/orm/persistence/operations/atomic_operation_spec.rb +58 -0
  102. data/spec/orm/persistence/operations/destroy_spec.rb +22 -0
  103. data/spec/orm/persistence/operations/embedded/destroy_spec.rb +71 -0
  104. data/spec/orm/persistence/operations/embedded/insert_spec.rb +59 -0
  105. data/spec/orm/persistence/operations/embedded/operation_helpers_spec.rb +92 -0
  106. data/spec/orm/persistence/operations/embedded/reload_spec.rb +67 -0
  107. data/spec/orm/persistence/operations/embedded/update_spec.rb +60 -0
  108. data/spec/orm/persistence/operations/insert_spec.rb +31 -0
  109. data/spec/orm/persistence/operations/reload_spec.rb +48 -0
  110. data/spec/orm/persistence/operations/suppress_spec.rb +17 -0
  111. data/spec/orm/persistence/operations/table_operation_helpers_spec.rb +98 -0
  112. data/spec/orm/persistence/operations/update_spec.rb +25 -0
  113. data/spec/orm/persistence/operations_spec.rb +58 -0
  114. data/spec/orm/relations/interface_spec.rb +188 -0
  115. data/spec/orm/relations/metadata_spec.rb +92 -15
  116. data/spec/orm/relations/proxy/embedded_in_polymorphic_spec.rb +37 -0
  117. data/spec/orm/relations/proxy/embedded_in_spec.rb +66 -0
  118. data/spec/orm/relations/proxy/embeds_many_spec.rb +651 -0
  119. data/spec/orm/relations/proxy/references_many_spec.rb +466 -2
  120. data/spec/orm/schema/column_family_spec.rb +21 -0
  121. data/spec/orm/schema/embedded_interface_spec.rb +181 -0
  122. data/spec/orm/schema/field_spec.rb +7 -0
  123. data/spec/orm/schema/table_interface_spec.rb +31 -1
  124. data/spec/shared/orm/id_factories.rb +44 -0
  125. data/spec/shared/orm/model_with_timestamps.rb +132 -0
  126. data/spec/shared/orm/persistence/a_persistence_embedded_operation_class.rb +3 -0
  127. data/spec/shared/orm/persistence/a_persistence_operation_class.rb +11 -0
  128. data/spec/shared/orm/persistence/a_persistence_table_operation_class.rb +11 -0
  129. data/spec/shared/orm/relations/proxy.rb +9 -2
  130. data/spec/spec_helper.rb +9 -0
  131. data/spec/support/mock_massive_record_connection.rb +2 -1
  132. metadata +106 -21
  133. data/spec/orm/cases/column_spec.rb +0 -49
  134. data/spec/orm/cases/id_factory_spec.rb +0 -92
  135. data/spec/orm/schema/column_interface_spec.rb +0 -136
@@ -45,7 +45,7 @@ describe "auto setting of ids" do
45
45
  end
46
46
  end
47
47
 
48
- MassiveRecord::ORM::IdFactory.should_receive(:next_for).with(Person).and_return(1)
48
+ MassiveRecord::ORM::IdFactory::AtomicIncrementation.should_receive(:next_for).with(Person).and_return(1)
49
49
  @person.id.should == "1"
50
50
 
51
51
  Person.class_eval { undef_method :default_id }
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe MassiveRecord::ORM::Table do
4
+ include SetUpHbaseConnectionBeforeAll
5
+ include SetTableNamesToTestTable
6
+
7
+ let(:old_id) { "old_id" }
8
+ let(:new_id) { "new_id" }
9
+
10
+ subject do
11
+ Person.create!(old_id, {
12
+ :name => "Thorbjorn",
13
+ :age => 22,
14
+ :points => 1
15
+ })
16
+ end
17
+
18
+ describe "#change_id!" do
19
+ describe "successfully" do
20
+ before do
21
+ subject.change_id! new_id
22
+ end
23
+
24
+ its(:id) { should eq new_id }
25
+
26
+ it "saves itself with new id" do
27
+ Person.find(new_id).should eq subject
28
+ end
29
+
30
+ it "has same attributes" do
31
+ Person.find(new_id).attributes.should eq subject.attributes
32
+ end
33
+
34
+ it "deletes the old id from the database" do
35
+ Person.should_not be_exists old_id
36
+ end
37
+
38
+ describe "with identity map" do
39
+ it "works as expected" do
40
+ MassiveRecord::ORM::IdentityMap.use do
41
+ person = Person.create!("id", {:name => "Thorbjorn", :age => 22, :points => 1})
42
+ person.change_id! "id-2"
43
+ Person.find("id-2").should eq person
44
+ Person.should_not be_exists "id"
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "unsuccessfully" do
51
+ it "raises error if unable to save new id" do
52
+ subject.should_receive(:save).and_return false
53
+ expect { subject.change_id! new_id }.to raise_error
54
+ end
55
+
56
+ it "raises error if unable to destroy old record" do
57
+ Person.any_instance.stub(:destroy).and_return false
58
+ expect { subject.change_id! new_id }.to raise_error
59
+ end
60
+ end
61
+ end
62
+ end
@@ -8,31 +8,50 @@ describe ModelWithoutDefaultId do
8
8
 
9
9
  context "with auto increment id" do
10
10
  its(:id) { be_nil }
11
- its(:auto_increment_id) { be_true }
11
+ its(:set_id_from_factory_before_create) { be_true }
12
12
 
13
13
  it "sets id to what next_id returns" do
14
- subject.should_receive(:next_id).and_return 1
14
+ MassiveRecord::ORM::IdFactory::AtomicIncrementation.should_receive(:next_for).and_return 1
15
15
  subject.save
16
16
  subject.id.should eq "1"
17
17
  end
18
18
 
19
19
  it "does nothing if the id is set before create" do
20
20
  subject.id = 2
21
- subject.should_not_receive(:next_id)
21
+ MassiveRecord::ORM::IdFactory::AtomicIncrementation.should_not_receive(:next_for)
22
22
  subject.save
23
23
  subject.id.should eq "2"
24
24
  end
25
+
26
+ it "is configurable which factory to use" do
27
+ id_factory_was = ModelWithoutDefaultId.id_factory
28
+ ModelWithoutDefaultId.id_factory = MassiveRecord::ORM::IdFactory::Timestamp
29
+
30
+ MassiveRecord::ORM::IdFactory::Timestamp.should_receive(:next_for).and_return 123
31
+ subject.save
32
+ subject.id.should eq "123"
33
+
34
+ ModelWithoutDefaultId.id_factory = MassiveRecord::ORM::IdFactory::AtomicIncrementation
35
+ end
25
36
  end
26
37
 
27
38
  context "without auto increment id" do
28
- before(:all) { subject.class.auto_increment_id = false }
29
- after(:all) { subject.class.auto_increment_id = true }
39
+ before(:all) { subject.class.set_id_from_factory_before_create = false }
40
+ after(:all) { subject.class.set_id_from_factory_before_create = true }
30
41
 
31
42
  its(:id) { be_nil }
32
- its(:auto_increment_id) { be_false }
43
+ its(:set_id_from_factory_before_create) { be_false }
33
44
 
34
45
  it "raises error as expected when id is missing" do
35
46
  expect { subject.save }.to raise_error MassiveRecord::ORM::IdMissing
36
47
  end
37
48
  end
49
+
50
+ it "is AtomicIncrementation on ORM::Table" do
51
+ Person.id_factory.instance.should be_instance_of MassiveRecord::ORM::IdFactory::AtomicIncrementation
52
+ end
53
+
54
+ it "is Timestamp on ORM::Embedded" do
55
+ Address.id_factory.instance.should be_instance_of MassiveRecord::ORM::IdFactory::Timestamp
56
+ end
38
57
  end
@@ -13,25 +13,28 @@ describe "default values" do
13
13
  end
14
14
 
15
15
  context "new record" do
16
- its(:addresses) { should eq Hash.new }
16
+ its(:dictionary) { should eq Hash.new }
17
17
  its(:points) { should eq 1 }
18
18
  its(:status) { should eq false }
19
+ its(:positive_as_default) { should eq true }
19
20
  its(:phone_numbers) { should eq [] }
20
21
  end
21
22
 
22
23
  context "persisted record" do
23
24
  before do
24
- subject.addresses = nil
25
+ subject.dictionary = nil
25
26
  subject.points = nil
26
27
  subject.status = nil
28
+ subject.positive_as_default = false
27
29
  subject.phone_numbers = nil
28
30
  subject.save!
29
31
  subject.reload
30
32
  end
31
33
 
32
- its(:addresses) { should be_nil }
34
+ its(:dictionary) { should be_nil }
33
35
  its(:points) { should be_nil }
34
36
  its(:status) { should be_nil }
37
+ its(:positive_as_default) { should be_false }
35
38
  its(:phone_numbers) { should eq [] }
36
39
  end
37
40
  end
@@ -3,126 +3,173 @@ require 'spec_helper'
3
3
  describe "dirty" do
4
4
  describe "dry run" do
5
5
  include MockMassiveRecordConnection
6
+ include TimeZoneHelper
6
7
 
7
- before do
8
- @person = Person.new '1', :name => "Alice", :age => 20, :email => "foo@bar.com"
9
- end
10
-
11
- it "should not be changed after created" do
12
- @person.should_not be_changed
13
- end
8
+ context "new record" do
9
+ subject { Person.new '1', :name => "Alice", :age => 20, :email => "foo@bar.com" }
10
+ let(:address) { Address.new("id1", :street => "foo") }
14
11
 
15
- it "should not be changed if attribute is set to what it currently is" do
16
- @person.name = "Alice"
17
- @person.should_not be_changed
18
- end
12
+ it "is not changed when first created" do
13
+ Person.new.should_not be_changed
14
+ end
19
15
 
20
- it "should notice changes" do
21
- @person.name = "Bob"
22
- @person.should be_changed
23
- end
16
+ it "initial values are changed" do
17
+ subject.should be_email_changed
18
+ end
24
19
 
25
- it "should notice changes in boolean values from false to true" do
26
- @person.status = !@person.status
27
- @person.should be_status_changed
28
- end
29
20
 
30
- it "should notice changes in boolean values from true to false" do
31
- @person.status = true
32
- @person.save
33
- @person.status = false
34
- @person.should be_status_changed
21
+ describe "changes in embedded relations" do
22
+ before { subject.addresses << address }
23
+
24
+ it "iterates over embedded relations and asks them if they have changes" do
25
+ should be_changed
26
+ end
27
+
28
+ it "includes addresses in changed" do
29
+ subject.changed.should include "addresses"
30
+ end
31
+
32
+ it "includes knowledge of changes" do
33
+ address.street = address.street + "_NEW"
34
+ subject.name = subject.name + "_NEW"
35
+ subject.changes.should eq({
36
+ "name" => [nil, "Alice_NEW"],
37
+ "age" => [nil, 20],
38
+ "email" => [nil, "foo@bar.com"],
39
+ "addresses" => {
40
+ "id1" => {
41
+ "street" => [nil, "foo_NEW"]
42
+ }
43
+ }
44
+ })
45
+ end
46
+ end
35
47
  end
36
48
 
37
- it "should not consider age set as string to the same as integer a change" do
38
- @person.age = "20"
39
- @person.should_not be_age_changed
40
- end
49
+ context "persisted" do
50
+ subject { Person.create '1', :name => "Alice", :age => 20, :email => "foo@bar.com" }
41
51
 
42
- it "should not consider age set as string back to original value a change" do
43
- @person.age = 30
44
- @person.age = "20"
45
- @person.should_not be_age_changed
46
- end
52
+ it "should not be changed if attribute is set to what it currently is" do
53
+ subject.name = "Alice"
54
+ should_not be_changed
55
+ end
47
56
 
57
+ it "should notice changes" do
58
+ subject.name = "Bob"
59
+ should be_changed
60
+ end
48
61
 
49
- it "should know when a attribute is set to it's original value" do
50
- original_name = @person.name
51
- @person.name = "Bob"
52
- @person.name = original_name
53
- @person.should_not be_changed
54
- end
62
+ it "should notice changes in boolean values from false to true" do
63
+ subject.status = !subject.status
64
+ should be_status_changed
65
+ end
55
66
 
56
- it "should always keep the objects original value as _was" do
57
- original_name = @person.name
58
- @person.name = "Bob"
59
- @person.name = "Foo"
60
- @person.name_was.should == original_name
61
- end
67
+ it "notices changes in time attributes" do
68
+ in_time_zone "utc" do
69
+ test = TestClass.new
70
+ test.tested_at = Time.now
71
+ test.should be_tested_at_changed
72
+ end
73
+ end
62
74
 
63
- it "should return what name was" do
64
- @person.name = "Bob"
65
- @person.name_was.should == "Alice"
66
- end
75
+ it "should notice changes in boolean values from true to false" do
76
+ subject.status = true
77
+ subject.save
78
+ subject.status = false
79
+ should be_status_changed
80
+ end
67
81
 
82
+ it "should not consider age set as string to the same as integer a change" do
83
+ subject.age = "20"
84
+ should_not be_age_changed
85
+ end
68
86
 
69
- describe "should reset changes" do
70
- it "on save" do
71
- @person.name = "Bob"
72
- @person.save
73
- @person.should_not be_changed
87
+ it "should not consider age set as string back to original value a change" do
88
+ subject.age = 30
89
+ subject.age = "20"
90
+ should_not be_age_changed
74
91
  end
75
92
 
76
- it "on save, but don't do it if save fails validation" do
77
- @person.should_receive(:valid?).and_return(false)
78
- @person.name = "Bob"
79
- @person.save
80
- @person.should be_changed
93
+
94
+ it "should know when a attribute is set to it's original value" do
95
+ original_name = subject.name
96
+ subject.name = "Bob"
97
+ subject.name = original_name
98
+ should_not be_changed
81
99
  end
82
100
 
83
- it "on save!" do
84
- @person.name = "Bob"
85
- @person.save!
86
- @person.should_not be_changed
101
+ it "should always keep the objects original value as _was" do
102
+ original_name = subject.name
103
+ subject.name = "Bob"
104
+ subject.name = "Foo"
105
+ subject.name_was.should == original_name
87
106
  end
88
107
 
89
- it "on reload" do
90
- @person.name = "Bob"
91
- @person.reload
92
- @person.should_not be_changed
108
+ it "should return what name was" do
109
+ subject.name = "Bob"
110
+ subject.name_was.should == "Alice"
93
111
  end
94
- end
95
112
 
96
- describe "previous changes" do
97
- it "should be blank before save" do
98
- @person.previous_changes.should be_blank
113
+
114
+ describe "should reset changes" do
115
+ it "on save" do
116
+ subject.name = "Bob"
117
+ subject.save
118
+ should_not be_changed
119
+ end
120
+
121
+ it "on save, but don't do it if save fails validation" do
122
+ subject.should_receive(:valid?).and_return(false)
123
+ subject.name = "Bob"
124
+ subject.save
125
+ should be_changed
126
+ end
127
+
128
+ it "on save!" do
129
+ subject.name = "Bob"
130
+ subject.save!
131
+ should_not be_changed
132
+ end
133
+
134
+ it "on reload" do
135
+ subject.name = "Bob"
136
+ subject.reload
137
+ should_not be_changed
138
+ end
99
139
  end
100
140
 
101
- it "should equal to changes before save" do
102
- @person.name = "Bob"
103
- changes_before_save = @person.changes
141
+ describe "previous changes" do
142
+ it "should be blank before after reload" do
143
+ subject.reload
144
+ subject.previous_changes.should be_blank
145
+ end
104
146
 
105
- @person.save
147
+ it "should equal to changes before save" do
148
+ subject.name = "Bob"
149
+ changes_before_save = subject.changes
106
150
 
107
- @person.changes.should be_empty
108
- @person.previous_changes.should == changes_before_save
109
- end
151
+ subject.save
110
152
 
111
- it "should equal to changes before save!" do
112
- @person.name = "Bob"
113
- changes_before_save = @person.changes
153
+ subject.changes.should be_empty
154
+ subject.previous_changes.should == changes_before_save
155
+ end
114
156
 
115
- @person.save!
157
+ it "should equal to changes before save!" do
158
+ subject.name = "Bob"
159
+ changes_before_save = subject.changes
116
160
 
117
- @person.changes.should be_empty
118
- @person.previous_changes.should == changes_before_save
119
- end
161
+ subject.save!
162
+
163
+ subject.changes.should be_empty
164
+ subject.previous_changes.should == changes_before_save
165
+ end
120
166
 
121
- it "should be nil after a reload" do
122
- @person.name = "Bob"
123
- @person.save
124
- @person.reload
125
- @person.previous_changes.should be_blank
167
+ it "should be nil after a reload" do
168
+ subject.name = "Bob"
169
+ subject.save
170
+ subject.reload
171
+ subject.previous_changes.should be_blank
172
+ end
126
173
  end
127
174
  end
128
175
  end
@@ -132,22 +179,23 @@ describe "dirty" do
132
179
  include SetUpHbaseConnectionBeforeAll
133
180
  include SetTableNamesToTestTable
134
181
 
182
+ subject { Person.new }
183
+
135
184
  before do
136
- @person = Person.new
137
- @person.id = "test"
138
- @person.points = "25"
139
- @person.date_of_birth = "19850730"
140
- @person.status = "0"
185
+ subject.id = "test"
186
+ subject.points = "25"
187
+ subject.date_of_birth = "19850730"
188
+ subject.status = "0"
141
189
  end
142
190
 
143
191
  it "should update dirty status correctly after a reload" do
144
- @person.addresses = {:something => "strage"}
145
- @person.save! :validate => false
146
- @person.reload
147
- @person.addresses = {}
148
- @person.save! :validate => false
149
- @person.reload
150
- @person.addresses.should == {}
192
+ subject.dictionary = {:something => "strage"}
193
+ subject.save! :validate => false
194
+ subject.reload
195
+ subject.dictionary = {}
196
+ subject.save! :validate => false
197
+ subject.reload
198
+ subject.dictionary.should == {}
151
199
  end
152
200
  end
153
201
  end