diff --git a/lib/rspec/rails/mocha.rb b/lib/rspec/rails/mocha.rb index cf5cd97..07a3cea 100644 --- a/lib/rspec/rails/mocha.rb +++ b/lib/rspec/rails/mocha.rb @@ -75,7 +75,7 @@ def mock_model(string_or_model_class, stubs = {}) stubs = stubs.reverse_merge(:persisted? => !!stubs[:id]) stubs = stubs.reverse_merge(:destroyed? => false) stubs = stubs.reverse_merge(:marked_for_destruction? => false) - stubs = stubs.reverse_merge(:errors => stub("errors", :count => 0, :[] => [])) + stubs = stubs.reverse_merge(:errors => stub("errors", :count => 0, :[] => [], :empty? => true)) stub("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m| m.extend ActiveModelInstanceMethods diff --git a/spec/mocha_spec.rb b/spec/mocha_spec.rb index e0b7c09..121667d 100644 --- a/spec/mocha_spec.rb +++ b/spec/mocha_spec.rb @@ -90,6 +90,7 @@ def create(*args) it "should have no errors" do create(Person).errors.count.should == 0 + create(Person).errors.empty?.should be_true create(Person).errors[:name].should == [] end end