spec/toy/dirty_spec.rb in toystore-0.10.1 vs spec/toy/dirty_spec.rb in toystore-0.10.2

- old
+ new

@@ -62,6 +62,27 @@ describe "#clone" do it "has no changes" do User.new.clone.should_not be_changed end end -end \ No newline at end of file + + # https://github.com/newtoy/toystore/issues/13 + describe "Overriding initialize and setting an attribute before calling super" do + before do + User.attribute(:name, String) + User.class_eval do + def initialize(*) + self.name = 'John' + super + end + end + end + + it "does not throw error" do + lambda { User.new }.should_not raise_error + end + + it "sets value" do + User.new.name.should == 'John' + end + end +end