From e9eb812c9e476abe8526a36b564644db3bfe6d25 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Fri, 19 Mar 2010 13:39:47 +1100 Subject: [PATCH] fix misbehaving spec --- spec/active_record/attribute_methods_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/active_record/attribute_methods_spec.rb b/spec/active_record/attribute_methods_spec.rb index b935116..2672d92 100644 --- a/spec/active_record/attribute_methods_spec.rb +++ b/spec/active_record/attribute_methods_spec.rb @@ -6,10 +6,11 @@ describe ValidatesTimeliness::ActiveRecord::AttributeMethods do end it "should define and call write method on first assign" do - Person.class_eval { @generated_methods = Set.new } - Person.send(:undef_method, :birth_date=) - @person.should_receive(:write_date_time_attribute) - @person.birth_date = "2000-01-01" + Person.class_eval { @generated_methods = Set.new; @_defined_class_methods = nil } + Person.send(:undef_method, :birth_date=) if Person.instance_methods.include?('birth_date=') + person = Person.new + person.should_receive(:write_date_time_attribute) + person.birth_date = "2000-01-01" end it "should call write_date_time_attribute when time attribute assigned value" do