Skip to content

Commit

Permalink
Stub model.errors.empty?
Browse files Browse the repository at this point in the history
  • Loading branch information
tessro committed Feb 4, 2011
1 parent 4d5ea10 commit 4eeda9d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/rails/mocha.rb
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/mocha_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4eeda9d

Please sign in to comment.