Skip to content

Commit

Permalink
Agregado test de attr_accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
nrainhart committed Oct 7, 2017
1 parent 0ce94d6 commit 8708939
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 11 additions & 0 deletions spec/attr_accessor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Grade

class Person
attr_accessor :grades
attr_accessor :saraza
end

describe 'Persistent attr_accessor' do
Expand All @@ -25,4 +26,14 @@ class Person
persisted_pepe = Person.all_instances[0]
expect(persisted_pepe.grades[0].value).to eq 7
end

it 'A not persistent attribute defined through attr_accessor should not be saved' do
pepe.grades = [Grade.new]
pepe.saraza = 5
pepe.save!
pepe.saraza = 0
pepe.refresh!
expect(pepe.saraza).to eq 0
end

end
7 changes: 0 additions & 7 deletions src/orm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,4 @@ class TrueClass

class FalseClass
include Boolean
end

class Person
has_one String, named: :first_name, default: ""
has_one String, named: :last_name, default: ""
has_one Numeric, named: :age, default: 0
has_one Boolean, named: :admin, default: true
end

0 comments on commit 8708939

Please sign in to comment.