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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/README.md +4 -4
- data/gemfiles/Gemfile.3.2.mysql2 +1 -1
- data/gemfiles/Gemfile.3.2.mysql2.lock +16 -11
- data/gemfiles/Gemfile.3.2.sqlite3 +1 -1
- data/gemfiles/Gemfile.3.2.sqlite3.lock +16 -11
- data/gemfiles/Gemfile.4.0.sqlite3 +1 -1
- data/gemfiles/Gemfile.4.0.sqlite3.lock +16 -11
- data/gemfiles/Gemfile.4.1.sqlite3 +1 -1
- data/gemfiles/Gemfile.4.1.sqlite3.lock +16 -11
- data/gemfiles/Gemfile.4.2.1.mysql2 +1 -1
- data/gemfiles/Gemfile.4.2.1.mysql2.lock +16 -11
- data/gemfiles/Gemfile.4.2.1.pg +1 -1
- data/gemfiles/Gemfile.4.2.1.pg.lock +16 -11
- data/gemfiles/Gemfile.4.2.1.sqlite3 +1 -1
- data/gemfiles/Gemfile.4.2.1.sqlite3.lock +16 -11
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +1 -1
- data/spec/active_type/extended_record/single_table_inheritance_spec.rb +6 -6
- data/spec/active_type/extended_record_spec.rb +32 -26
- data/spec/active_type/nested_attributes_spec.rb +51 -51
- data/spec/active_type/object_spec.rb +44 -33
- data/spec/active_type/record_spec.rb +15 -11
- data/spec/active_type/util_spec.rb +25 -25
- data/spec/integration/holidays_spec.rb +13 -13
- data/spec/integration/shape_spec.rb +12 -14
- data/spec/integration/sign_in_spec.rb +12 -12
- data/spec/integration/sign_up_spec.rb +9 -9
- data/spec/shared_examples/accessors.rb +3 -3
- data/spec/shared_examples/belongs_to.rb +2 -2
- data/spec/shared_examples/coercible_columns.rb +27 -27
- data/spec/shared_examples/constructor.rb +2 -2
- data/spec/shared_examples/defaults.rb +10 -10
- data/spec/shared_examples/dirty_tracking.rb +4 -4
- data/spec/shared_examples/dupable.rb +4 -4
- data/spec/shared_examples/mass_assignment.rb +1 -1
- metadata +2 -2
| @@ -38,11 +38,11 @@ describe "ActiveType::Record[ActiveRecord::Base]" do | |
| 38 38 | 
             
              subject { ExtendedRecordSpec::ExtendedRecord.new }
         | 
| 39 39 |  | 
| 40 40 | 
             
              it 'is inherits from the base type' do
         | 
| 41 | 
            -
                subject. | 
| 41 | 
            +
                expect(subject).to be_a(ExtendedRecordSpec::BaseRecord)
         | 
| 42 42 | 
             
              end
         | 
| 43 43 |  | 
| 44 44 | 
             
              it 'has the same model name as the base class' do
         | 
| 45 | 
            -
                subject.class.model_name.singular. | 
| 45 | 
            +
                expect(subject.class.model_name.singular).to eq(ExtendedRecordSpec::BaseRecord.model_name.singular)
         | 
| 46 46 | 
             
              end
         | 
| 47 47 |  | 
| 48 48 | 
             
              describe 'constructors' do
         | 
| @@ -57,7 +57,7 @@ describe "ActiveType::Record[ActiveRecord::Base]" do | |
| 57 57 | 
             
                  subject.persisted_string = "string"
         | 
| 58 58 | 
             
                  subject.another_virtual_string = "string"
         | 
| 59 59 |  | 
| 60 | 
            -
                  subject.attributes. | 
| 60 | 
            +
                  expect(subject.attributes).to eq({
         | 
| 61 61 | 
             
                    "another_virtual_string" => "string",
         | 
| 62 62 | 
             
                    "id" => nil,
         | 
| 63 63 | 
             
                    "persisted_string" => "string",
         | 
| @@ -65,7 +65,7 @@ describe "ActiveType::Record[ActiveRecord::Base]" do | |
| 65 65 | 
             
                    "persisted_time" => nil,
         | 
| 66 66 | 
             
                    "persisted_date" => nil,
         | 
| 67 67 | 
             
                    "persisted_boolean" => nil
         | 
| 68 | 
            -
                  }
         | 
| 68 | 
            +
                  })
         | 
| 69 69 | 
             
                end
         | 
| 70 70 |  | 
| 71 71 | 
             
              end
         | 
| @@ -77,9 +77,9 @@ describe "ActiveType::Record[ActiveRecord::Base]" do | |
| 77 77 | 
             
              describe 'persistence' do
         | 
| 78 78 | 
             
                it 'persists to the database' do
         | 
| 79 79 | 
             
                  subject.persisted_string = "persisted string"
         | 
| 80 | 
            -
                  subject.save. | 
| 80 | 
            +
                  expect(subject.save).to eq(true)
         | 
| 81 81 |  | 
| 82 | 
            -
                  subject.class.find(subject.id).persisted_string. | 
| 82 | 
            +
                  expect(subject.class.find(subject.id).persisted_string).to eq("persisted string")
         | 
| 83 83 | 
             
                end
         | 
| 84 84 | 
             
              end
         | 
| 85 85 |  | 
| @@ -87,13 +87,13 @@ describe "ActiveType::Record[ActiveRecord::Base]" do | |
| 87 87 | 
             
                it 'returns an instance of the extended model' do
         | 
| 88 88 | 
             
                  subject.save
         | 
| 89 89 |  | 
| 90 | 
            -
                  subject.class.find(subject.id). | 
| 90 | 
            +
                  expect(subject.class.find(subject.id)).to be_a(subject.class)
         | 
| 91 91 | 
             
                end
         | 
| 92 92 | 
             
              end
         | 
| 93 93 |  | 
| 94 94 | 
             
              describe '.base_class' do
         | 
| 95 95 | 
             
                it 'is the base class inherited from' do
         | 
| 96 | 
            -
                  subject.class.base_class. | 
| 96 | 
            +
                  expect(subject.class.base_class).to eq(ExtendedRecordSpec::BaseRecord)
         | 
| 97 97 | 
             
                end
         | 
| 98 98 | 
             
              end
         | 
| 99 99 |  | 
| @@ -104,11 +104,11 @@ describe "class ... < ActiveType::Record[ActiveRecord::Base]" do | |
| 104 104 | 
             
              subject { ExtendedRecordSpec::InheritingFromExtendedRecord.new }
         | 
| 105 105 |  | 
| 106 106 | 
             
              it 'is inherits from the base type' do
         | 
| 107 | 
            -
                subject. | 
| 107 | 
            +
                expect(subject).to be_a(ExtendedRecordSpec::ExtendedRecord)
         | 
| 108 108 | 
             
              end
         | 
| 109 109 |  | 
| 110 110 | 
             
              it 'has the same model name as the base class' do
         | 
| 111 | 
            -
                subject.class.model_name.singular. | 
| 111 | 
            +
                expect(subject.class.model_name.singular).to eq(ExtendedRecordSpec::BaseRecord.model_name.singular)
         | 
| 112 112 | 
             
              end
         | 
| 113 113 |  | 
| 114 114 | 
             
              describe '#attributes' do
         | 
| @@ -118,7 +118,7 @@ describe "class ... < ActiveType::Record[ActiveRecord::Base]" do | |
| 118 118 | 
             
                  subject.another_virtual_string = "string"
         | 
| 119 119 | 
             
                  subject.yet_another_virtual_string = "string"
         | 
| 120 120 |  | 
| 121 | 
            -
                  subject.attributes. | 
| 121 | 
            +
                  expect(subject.attributes).to eq({
         | 
| 122 122 | 
             
                    "another_virtual_string" => "string",
         | 
| 123 123 | 
             
                    "yet_another_virtual_string" => "string",
         | 
| 124 124 | 
             
                    "id" => nil,
         | 
| @@ -127,7 +127,7 @@ describe "class ... < ActiveType::Record[ActiveRecord::Base]" do | |
| 127 127 | 
             
                    "persisted_time" => nil,
         | 
| 128 128 | 
             
                    "persisted_date" => nil,
         | 
| 129 129 | 
             
                    "persisted_boolean" => nil
         | 
| 130 | 
            -
                  }
         | 
| 130 | 
            +
                  })
         | 
| 131 131 | 
             
                end
         | 
| 132 132 |  | 
| 133 133 | 
             
              end
         | 
| @@ -135,9 +135,9 @@ describe "class ... < ActiveType::Record[ActiveRecord::Base]" do | |
| 135 135 | 
             
              describe 'persistence' do
         | 
| 136 136 | 
             
                it 'persists to the database' do
         | 
| 137 137 | 
             
                  subject.persisted_string = "persisted string"
         | 
| 138 | 
            -
                  subject.save. | 
| 138 | 
            +
                  expect(subject.save).to eq(true)
         | 
| 139 139 |  | 
| 140 | 
            -
                  subject.class.find(subject.id).persisted_string. | 
| 140 | 
            +
                  expect(subject.class.find(subject.id).persisted_string).to eq("persisted string")
         | 
| 141 141 | 
             
                end
         | 
| 142 142 | 
             
              end
         | 
| 143 143 |  | 
| @@ -145,7 +145,7 @@ describe "class ... < ActiveType::Record[ActiveRecord::Base]" do | |
| 145 145 | 
             
                it 'returns an instance of the inheriting model' do
         | 
| 146 146 | 
             
                  subject.save
         | 
| 147 147 |  | 
| 148 | 
            -
                  subject.class.find(subject.id). | 
| 148 | 
            +
                  expect(subject.class.find(subject.id)).to be_a(subject.class)
         | 
| 149 149 | 
             
                end
         | 
| 150 150 | 
             
              end
         | 
| 151 151 |  | 
| @@ -156,11 +156,11 @@ describe "ActiveType::Record[ActiveType::Record]" do | |
| 156 156 | 
             
              subject { ExtendedRecordSpec::ExtendedActiveTypeRecord.new }
         | 
| 157 157 |  | 
| 158 158 | 
             
              it 'is inherits from the base type' do
         | 
| 159 | 
            -
                subject. | 
| 159 | 
            +
                expect(subject).to be_a(ExtendedRecordSpec::BaseActiveTypeRecord)
         | 
| 160 160 | 
             
              end
         | 
| 161 161 |  | 
| 162 162 | 
             
              it 'has the same model name as the base class' do
         | 
| 163 | 
            -
                subject.class.model_name.singular. | 
| 163 | 
            +
                expect(subject.class.model_name.singular).to eq(ExtendedRecordSpec::BaseActiveTypeRecord.model_name.singular)
         | 
| 164 164 | 
             
              end
         | 
| 165 165 |  | 
| 166 166 | 
             
              describe 'constructors' do
         | 
| @@ -175,7 +175,7 @@ describe "ActiveType::Record[ActiveType::Record]" do | |
| 175 175 | 
             
                  subject.persisted_string = "string"
         | 
| 176 176 | 
             
                  subject.virtual_string = "string"
         | 
| 177 177 |  | 
| 178 | 
            -
                  subject.attributes. | 
| 178 | 
            +
                  expect(subject.attributes).to eq({
         | 
| 179 179 | 
             
                    "virtual_string" => "string",
         | 
| 180 180 | 
             
                    "another_virtual_string" => nil,
         | 
| 181 181 | 
             
                    "id" => nil,
         | 
| @@ -184,7 +184,7 @@ describe "ActiveType::Record[ActiveType::Record]" do | |
| 184 184 | 
             
                    "persisted_time" => nil,
         | 
| 185 185 | 
             
                    "persisted_date" => nil,
         | 
| 186 186 | 
             
                    "persisted_boolean" => nil
         | 
| 187 | 
            -
                  }
         | 
| 187 | 
            +
                  })
         | 
| 188 188 | 
             
                end
         | 
| 189 189 |  | 
| 190 190 | 
             
              end
         | 
| @@ -196,17 +196,23 @@ describe "ActiveType::Record[ActiveType::Record]" do | |
| 196 196 | 
             
              describe 'validations' do
         | 
| 197 197 | 
             
                subject { ExtendedRecordSpec::ExtendedRecordWithValidations.new }
         | 
| 198 198 |  | 
| 199 | 
            -
                it  | 
| 200 | 
            -
             | 
| 201 | 
            -
                 | 
| 199 | 
            +
                it 'has 1 error_on' do
         | 
| 200 | 
            +
                  expect(subject.error_on(:persisted_string).size).to eq(1)
         | 
| 201 | 
            +
                end
         | 
| 202 | 
            +
                it 'has 1 error_on' do
         | 
| 203 | 
            +
                  expect(subject.error_on(:virtual_string).size).to eq(1)
         | 
| 204 | 
            +
                end
         | 
| 205 | 
            +
                it 'has 1 error_on' do
         | 
| 206 | 
            +
                  expect(subject.error_on(:another_virtual_string).size).to eq(1)
         | 
| 207 | 
            +
                end
         | 
| 202 208 | 
             
              end
         | 
| 203 209 |  | 
| 204 210 | 
             
              describe 'persistence' do
         | 
| 205 211 | 
             
                it 'persists to the database' do
         | 
| 206 212 | 
             
                  subject.persisted_string = "persisted string"
         | 
| 207 | 
            -
                  subject.save. | 
| 213 | 
            +
                  expect(subject.save).to eq(true)
         | 
| 208 214 |  | 
| 209 | 
            -
                  subject.class.find(subject.id).persisted_string. | 
| 215 | 
            +
                  expect(subject.class.find(subject.id).persisted_string).to eq("persisted string")
         | 
| 210 216 | 
             
                end
         | 
| 211 217 | 
             
              end
         | 
| 212 218 |  | 
| @@ -214,13 +220,13 @@ describe "ActiveType::Record[ActiveType::Record]" do | |
| 214 220 | 
             
                it 'returns an instance of the extended model' do
         | 
| 215 221 | 
             
                  subject.save
         | 
| 216 222 |  | 
| 217 | 
            -
                  subject.class.find(subject.id). | 
| 223 | 
            +
                  expect(subject.class.find(subject.id)).to be_a(subject.class)
         | 
| 218 224 | 
             
                end
         | 
| 219 225 | 
             
              end
         | 
| 220 226 |  | 
| 221 227 | 
             
              describe '.base_class' do
         | 
| 222 228 | 
             
                it 'is the base class inherited from' do
         | 
| 223 | 
            -
                  subject.class.base_class. | 
| 229 | 
            +
                  expect(subject.class.base_class).to eq(ExtendedRecordSpec::BaseActiveTypeRecord)
         | 
| 224 230 | 
             
                end
         | 
| 225 231 | 
             
              end
         | 
| 226 232 |  | 
| @@ -54,16 +54,16 @@ describe "ActiveType::Object" do | |
| 54 54 | 
             
                end
         | 
| 55 55 |  | 
| 56 56 | 
             
                def should_assign_and_persist(assign, persist = assign)
         | 
| 57 | 
            -
                  subject.records.map(&:persisted_string). | 
| 58 | 
            -
                  subject.save. | 
| 59 | 
            -
                  NestedAttributesSpec::Record.all.map(&:persisted_string). | 
| 57 | 
            +
                  expect(subject.records.map(&:persisted_string)).to eq(assign)
         | 
| 58 | 
            +
                  expect(subject.save).to eq(true)
         | 
| 59 | 
            +
                  expect(NestedAttributesSpec::Record.all.map(&:persisted_string)).to match_array(persist)
         | 
| 60 60 | 
             
                end
         | 
| 61 61 |  | 
| 62 62 |  | 
| 63 63 | 
             
                context 'with no records assigned' do
         | 
| 64 64 |  | 
| 65 65 | 
             
                  it 'can save' do
         | 
| 66 | 
            -
                    subject.save. | 
| 66 | 
            +
                    expect(subject.save).to eq(true)
         | 
| 67 67 | 
             
                  end
         | 
| 68 68 |  | 
| 69 69 | 
             
                end
         | 
| @@ -72,7 +72,7 @@ describe "ActiveType::Object" do | |
| 72 72 |  | 
| 73 73 | 
             
                  it 'will do nothing' do
         | 
| 74 74 | 
             
                    subject.records_attributes = nil
         | 
| 75 | 
            -
                    subject.records. | 
| 75 | 
            +
                    expect(subject.records).to be_nil
         | 
| 76 76 | 
             
                  end
         | 
| 77 77 |  | 
| 78 78 | 
             
                end
         | 
| @@ -176,7 +176,7 @@ describe "ActiveType::Object" do | |
| 176 176 | 
             
                      { :id => existing.id, :_destroy => "true" },
         | 
| 177 177 | 
             
                    ]
         | 
| 178 178 | 
             
                    should_assign_and_persist(["do not delete this"], ["do not delete this"])
         | 
| 179 | 
            -
                    subject.records.size. | 
| 179 | 
            +
                    expect(subject.records.size).to eq(1)
         | 
| 180 180 | 
             
                  end
         | 
| 181 181 |  | 
| 182 182 | 
             
                  it 'destroys records on _destroy => trueish if allowed' do
         | 
| @@ -197,7 +197,7 @@ describe "ActiveType::Object" do | |
| 197 197 | 
             
                      { :id => existing[3].id, :_destroy => "0" },
         | 
| 198 198 | 
             
                    ]
         | 
| 199 199 | 
             
                    should_assign_and_persist(["delete this", "delete this", "delete this", "keep this"], ["keep this"])
         | 
| 200 | 
            -
                    subject.records.size. | 
| 200 | 
            +
                    expect(subject.records.size).to eq(1)
         | 
| 201 201 | 
             
                  end
         | 
| 202 202 |  | 
| 203 203 | 
             
                end
         | 
| @@ -264,8 +264,8 @@ describe "ActiveType::Object" do | |
| 264 264 | 
             
                      NestedAttributesSpec::Record.new(:fail_on_save => true),
         | 
| 265 265 | 
             
                    ]
         | 
| 266 266 |  | 
| 267 | 
            -
                    subject.save. | 
| 268 | 
            -
                    NestedAttributesSpec::Record.count. | 
| 267 | 
            +
                    expect(subject.save).to be_falsey
         | 
| 268 | 
            +
                    expect(NestedAttributesSpec::Record.count).to eq(0)
         | 
| 269 269 |  | 
| 270 270 | 
             
                    # note that other children would be saved and not be rolled back
         | 
| 271 271 | 
             
                    # this is also true for regular nested attributes
         | 
| @@ -278,7 +278,7 @@ describe "ActiveType::Object" do | |
| 278 278 | 
             
                  describe '#valid?' do
         | 
| 279 279 |  | 
| 280 280 | 
             
                    it 'is true if there are no records assigned' do
         | 
| 281 | 
            -
                      subject.valid | 
| 281 | 
            +
                      expect(subject.valid?).to eq(true)
         | 
| 282 282 | 
             
                    end
         | 
| 283 283 |  | 
| 284 284 | 
             
                    it 'is true if all records are valid' do
         | 
| @@ -287,7 +287,7 @@ describe "ActiveType::Object" do | |
| 287 287 | 
             
                        NestedAttributesSpec::Record.new,
         | 
| 288 288 | 
             
                      ]
         | 
| 289 289 |  | 
| 290 | 
            -
                      subject.valid | 
| 290 | 
            +
                      expect(subject.valid?).to eq(true)
         | 
| 291 291 | 
             
                    end
         | 
| 292 292 |  | 
| 293 293 | 
             
                    it 'is false if one child has an error' do
         | 
| @@ -296,7 +296,7 @@ describe "ActiveType::Object" do | |
| 296 296 | 
             
                        NestedAttributesSpec::Record.new(:error => 'some error'),
         | 
| 297 297 | 
             
                      ]
         | 
| 298 298 |  | 
| 299 | 
            -
                      subject.valid | 
| 299 | 
            +
                      expect(subject.valid?).to be_falsey
         | 
| 300 300 | 
             
                    end
         | 
| 301 301 |  | 
| 302 302 | 
             
                    it 'is copies the error to the record' do
         | 
| @@ -306,7 +306,7 @@ describe "ActiveType::Object" do | |
| 306 306 | 
             
                      ]
         | 
| 307 307 |  | 
| 308 308 | 
             
                      subject.valid?
         | 
| 309 | 
            -
                      subject.errors["records.base"]. | 
| 309 | 
            +
                      expect(subject.errors["records.base"]).to eq(['some error'])
         | 
| 310 310 | 
             
                    end
         | 
| 311 311 |  | 
| 312 312 | 
             
                  end
         | 
| @@ -333,20 +333,20 @@ describe "ActiveType::Object" do | |
| 333 333 |  | 
| 334 334 | 
             
                def should_assign_and_persist(assign, persist = assign)
         | 
| 335 335 | 
             
                  if assign
         | 
| 336 | 
            -
                    subject.record. | 
| 337 | 
            -
                    subject.record.persisted_string. | 
| 336 | 
            +
                    expect(subject.record).to be_present
         | 
| 337 | 
            +
                    expect(subject.record.persisted_string).to eq(assign)
         | 
| 338 338 | 
             
                  else
         | 
| 339 | 
            -
                    subject.record. | 
| 339 | 
            +
                    expect(subject.record).to be_nil
         | 
| 340 340 | 
             
                  end
         | 
| 341 | 
            -
                  subject.save. | 
| 342 | 
            -
                  NestedAttributesSpec::Record.all.map(&:persisted_string). | 
| 341 | 
            +
                  expect(subject.save).to eq(true)
         | 
| 342 | 
            +
                  expect(NestedAttributesSpec::Record.all.map(&:persisted_string)).to eq(persist ? [persist] : [])
         | 
| 343 343 | 
             
                end
         | 
| 344 344 |  | 
| 345 345 |  | 
| 346 346 | 
             
                context 'with no record assigned' do
         | 
| 347 347 |  | 
| 348 348 | 
             
                  it 'can save' do
         | 
| 349 | 
            -
                    subject.save. | 
| 349 | 
            +
                    expect(subject.save).to eq(true)
         | 
| 350 350 | 
             
                  end
         | 
| 351 351 |  | 
| 352 352 | 
             
                end
         | 
| @@ -355,7 +355,7 @@ describe "ActiveType::Object" do | |
| 355 355 |  | 
| 356 356 | 
             
                  it 'will do nothing' do
         | 
| 357 357 | 
             
                    subject.record_attributes = nil
         | 
| 358 | 
            -
                    subject.record. | 
| 358 | 
            +
                    expect(subject.record).to be_nil
         | 
| 359 359 | 
             
                  end
         | 
| 360 360 |  | 
| 361 361 | 
             
                end
         | 
| @@ -423,7 +423,7 @@ describe "ActiveType::Object" do | |
| 423 423 | 
             
                    subject.record_attributes = { :id => record.id, :_destroy => true }
         | 
| 424 424 |  | 
| 425 425 | 
             
                    should_assign_and_persist("existing string", nil)
         | 
| 426 | 
            -
                    subject.record. | 
| 426 | 
            +
                    expect(subject.record).to eq(nil)
         | 
| 427 427 | 
             
                  end
         | 
| 428 428 |  | 
| 429 429 | 
             
                  it 'raises an error if the assigned record does not match the id' do
         | 
| @@ -446,26 +446,26 @@ describe "ActiveType::Object" do | |
| 446 446 | 
             
                  describe '#valid?' do
         | 
| 447 447 |  | 
| 448 448 | 
             
                    it 'is true if there is no record assigned' do
         | 
| 449 | 
            -
                      subject.valid | 
| 449 | 
            +
                      expect(subject.valid?).to eq(true)
         | 
| 450 450 | 
             
                    end
         | 
| 451 451 |  | 
| 452 452 | 
             
                    it 'is true if the assigned record is valid' do
         | 
| 453 453 | 
             
                      subject.record = NestedAttributesSpec::Record.new
         | 
| 454 454 |  | 
| 455 | 
            -
                      subject.valid | 
| 455 | 
            +
                      expect(subject.valid?).to eq(true)
         | 
| 456 456 | 
             
                    end
         | 
| 457 457 |  | 
| 458 458 | 
             
                    it 'is false the assigned record has an error' do
         | 
| 459 459 | 
             
                      subject.record = NestedAttributesSpec::Record.new(:error => 'some error')
         | 
| 460 460 |  | 
| 461 | 
            -
                      subject.valid | 
| 461 | 
            +
                      expect(subject.valid?).to be_falsey
         | 
| 462 462 | 
             
                    end
         | 
| 463 463 |  | 
| 464 464 | 
             
                    it 'is copies the error to the record' do
         | 
| 465 465 | 
             
                      subject.record = NestedAttributesSpec::Record.new(:error => 'some error')
         | 
| 466 466 |  | 
| 467 467 | 
             
                      subject.valid?
         | 
| 468 | 
            -
                      subject.errors["record.base"]. | 
| 468 | 
            +
                      expect(subject.errors["record.base"]).to eq(['some error'])
         | 
| 469 469 | 
             
                    end
         | 
| 470 470 |  | 
| 471 471 | 
             
                  end
         | 
| @@ -492,10 +492,10 @@ describe "ActiveType::Object" do | |
| 492 492 | 
             
                    subject.record_attributes = { :persisted_string => "string" }
         | 
| 493 493 | 
             
                    subject.another_record_attributes = {:persisted_string => "another string"}
         | 
| 494 494 |  | 
| 495 | 
            -
                    subject.record.persisted_string. | 
| 496 | 
            -
                    subject.another_record.persisted_string. | 
| 497 | 
            -
                    subject.save. | 
| 498 | 
            -
                    NestedAttributesSpec::Record.all.map(&:persisted_string). | 
| 495 | 
            +
                    expect(subject.record.persisted_string).to eq("string")
         | 
| 496 | 
            +
                    expect(subject.another_record.persisted_string).to eq("another string")
         | 
| 497 | 
            +
                    expect(subject.save).to eq(true)
         | 
| 498 | 
            +
                    expect(NestedAttributesSpec::Record.all.map(&:persisted_string)).to match_array(["string", "another string"])
         | 
| 499 499 | 
             
                  end
         | 
| 500 500 |  | 
| 501 501 | 
             
                  it 'allows overriding of the accessor' do
         | 
| @@ -509,12 +509,12 @@ describe "ActiveType::Object" do | |
| 509 509 | 
             
                      end
         | 
| 510 510 | 
             
                    end.new
         | 
| 511 511 |  | 
| 512 | 
            -
                    subject. | 
| 512 | 
            +
                    expect(subject).to receive(:reached)
         | 
| 513 513 | 
             
                    subject.record_attributes = { :persisted_string => "string" }
         | 
| 514 514 |  | 
| 515 | 
            -
                    subject.record.persisted_string. | 
| 516 | 
            -
                    subject.save. | 
| 517 | 
            -
                    NestedAttributesSpec::Record.all.map(&:persisted_string). | 
| 515 | 
            +
                    expect(subject.record.persisted_string).to eq("string")
         | 
| 516 | 
            +
                    expect(subject.save).to eq(true)
         | 
| 517 | 
            +
                    expect(NestedAttributesSpec::Record.all.map(&:persisted_string)).to match_array(["string"])
         | 
| 518 518 | 
             
                  end
         | 
| 519 519 |  | 
| 520 520 | 
             
                end
         | 
| @@ -532,8 +532,8 @@ describe "ActiveType::Object" do | |
| 532 532 | 
             
                    subject.global_records_attributes = { 1 => { :persisted_string => "string" } }
         | 
| 533 533 | 
             
                    subject.global_record_attributes = { :persisted_string => "string" }
         | 
| 534 534 |  | 
| 535 | 
            -
                    subject.global_records.first. | 
| 536 | 
            -
                    subject.global_record. | 
| 535 | 
            +
                    expect(subject.global_records.first).to be_a(GlobalRecord)
         | 
| 536 | 
            +
                    expect(subject.global_record).to be_a(GlobalRecord)
         | 
| 537 537 | 
             
                  end
         | 
| 538 538 |  | 
| 539 539 | 
             
                end
         | 
| @@ -554,15 +554,15 @@ describe "ActiveType::Object" do | |
| 554 554 | 
             
                    subject.records_attributes = { 1 => { :persisted_string => "string" } }
         | 
| 555 555 | 
             
                    subject.record_attributes = { :persisted_string => "string" }
         | 
| 556 556 |  | 
| 557 | 
            -
                    subject.records.first. | 
| 558 | 
            -
                    subject.record. | 
| 557 | 
            +
                    expect(subject.records.first).to be_a(NestedAttributesSpec::Record)
         | 
| 558 | 
            +
                    expect(subject.record).to be_a(NestedAttributesSpec::Record)
         | 
| 559 559 | 
             
                  end
         | 
| 560 560 |  | 
| 561 561 | 
             
                  it 'evals the scope lazily in the instance' do
         | 
| 562 562 | 
             
                    subject.default_value = "default value"
         | 
| 563 563 | 
             
                    subject.default_records_attributes = [{}]
         | 
| 564 564 |  | 
| 565 | 
            -
                    subject.default_records.map(&:persisted_string). | 
| 565 | 
            +
                    expect(subject.default_records.map(&:persisted_string)).to eq(["default value"])
         | 
| 566 566 | 
             
                  end
         | 
| 567 567 |  | 
| 568 568 | 
             
                  it 'caches the scope' do
         | 
| @@ -571,7 +571,7 @@ describe "ActiveType::Object" do | |
| 571 571 | 
             
                    subject.default_value = "another default value"
         | 
| 572 572 | 
             
                    subject.default_records_attributes = [{}]
         | 
| 573 573 |  | 
| 574 | 
            -
                    subject.default_records.map(&:persisted_string). | 
| 574 | 
            +
                    expect(subject.default_records.map(&:persisted_string)).to eq(["default value", "default value"])
         | 
| 575 575 | 
             
                  end
         | 
| 576 576 |  | 
| 577 577 | 
             
                  it 'caches the scope per instance' do
         | 
| @@ -582,7 +582,7 @@ describe "ActiveType::Object" do | |
| 582 582 | 
             
                    another_subject.default_value = "another default value"
         | 
| 583 583 | 
             
                    another_subject.default_records_attributes = [{}]
         | 
| 584 584 |  | 
| 585 | 
            -
                    another_subject.default_records.map(&:persisted_string). | 
| 585 | 
            +
                    expect(another_subject.default_records.map(&:persisted_string)).to eq(["another default value"])
         | 
| 586 586 | 
             
                  end
         | 
| 587 587 |  | 
| 588 588 | 
             
                  it 'raises an error if the child record is not found via the scope' do
         | 
| @@ -620,7 +620,7 @@ describe "ActiveType::Object" do | |
| 620 620 |  | 
| 621 621 | 
             
                  it 'nests_many uses the build_scope to find records' do
         | 
| 622 622 | 
             
                    subject.records_attributes = [{}]
         | 
| 623 | 
            -
                    subject.records.first.persisted_string. | 
| 623 | 
            +
                    expect(subject.records.first.persisted_string).to eq('buildable')
         | 
| 624 624 | 
             
                  end
         | 
| 625 625 |  | 
| 626 626 | 
             
                  it 'nests_one uses the find_scope to find records' do
         | 
| @@ -639,7 +639,7 @@ describe "ActiveType::Object" do | |
| 639 639 |  | 
| 640 640 | 
             
                  it 'nests_one uses the build_scope to find records' do
         | 
| 641 641 | 
             
                    subject.record_attributes = {}
         | 
| 642 | 
            -
                    subject.record.persisted_string. | 
| 642 | 
            +
                    expect(subject.record.persisted_string).to eq('buildable')
         | 
| 643 643 | 
             
                  end
         | 
| 644 644 |  | 
| 645 645 | 
             
                end
         | 
| @@ -665,14 +665,14 @@ describe "ActiveType::Object" do | |
| 665 665 | 
             
                  end
         | 
| 666 666 |  | 
| 667 667 | 
             
                  it 'accepts a :default value' do
         | 
| 668 | 
            -
                    subject.records.map(&:persisted_string). | 
| 669 | 
            -
                    subject.record.persisted_string. | 
| 668 | 
            +
                    expect(subject.records.map(&:persisted_string)).to eq(["default"])
         | 
| 669 | 
            +
                    expect(subject.record.persisted_string).to eq("default")
         | 
| 670 670 | 
             
                  end
         | 
| 671 671 |  | 
| 672 672 | 
             
                  it 'computes the value lazily' do
         | 
| 673 | 
            -
                    subject. | 
| 674 | 
            -
                    subject.records.map(&:persisted_string). | 
| 675 | 
            -
                    subject.record.persisted_string. | 
| 673 | 
            +
                    allow(subject).to receive_messages :default_record => NestedAttributesSpec::Record.new(:persisted_string => "other default")
         | 
| 674 | 
            +
                    expect(subject.records.map(&:persisted_string)).to eq(["other default"])
         | 
| 675 | 
            +
                    expect(subject.record.persisted_string).to eq("other default")
         | 
| 676 676 | 
             
                  end
         | 
| 677 677 |  | 
| 678 678 | 
             
                end
         | 
| @@ -684,8 +684,8 @@ end | |
| 684 684 | 
             
            describe "ActiveType::Record" do
         | 
| 685 685 |  | 
| 686 686 | 
             
              it 'supports nested attributes' do
         | 
| 687 | 
            -
                ActiveType::Record. | 
| 688 | 
            -
                ActiveType::Record. | 
| 687 | 
            +
                expect(ActiveType::Record).to respond_to(:nests_one)
         | 
| 688 | 
            +
                expect(ActiveType::Record).to respond_to(:nests_many)
         | 
| 689 689 | 
             
              end
         | 
| 690 690 |  | 
| 691 691 | 
             
            end
         | 
| @@ -693,8 +693,8 @@ end | |
| 693 693 | 
             
            describe "ActiveType::Record" do
         | 
| 694 694 |  | 
| 695 695 | 
             
              it 'supports nested attributes' do
         | 
| 696 | 
            -
                ActiveType::Record[NestedAttributesSpec::Record]. | 
| 697 | 
            -
                ActiveType::Record[NestedAttributesSpec::Record]. | 
| 696 | 
            +
                expect(ActiveType::Record[NestedAttributesSpec::Record]).to respond_to(:nests_one)
         | 
| 697 | 
            +
                expect(ActiveType::Record[NestedAttributesSpec::Record]).to respond_to(:nests_many)
         | 
| 698 698 | 
             
              end
         | 
| 699 699 |  | 
| 700 700 | 
             
            end
         |