Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created November 6, 2010 15:28
Show Gist options
  • Select an option

  • Save rubiii/665482 to your computer and use it in GitHub Desktop.

Select an option

Save rubiii/665482 to your computer and use it in GitHub Desktop.
describe "#expects" do
before { something.expects(:some_method) }
around do |example|
begin
example.run
rescue Mocha::ExpectationError => e
e.message.should include("expected exactly once, not yet invoked: SomeObject.some_method")
end
end
it "should fail, raise an expectation_error and still pass (weird)" do
end
end
describe "#expects" do
before { something.expects(:some_method) }
it "should fail" do
expect { verify_mocks_for_rspec }.to raise_error(
Mocha::ExpectationError,
/expected exactly once, not yet invoked: SomeObject.some_method/
)
teardown_mocks_for_rspec
end
end
@rubiii

rubiii commented Nov 7, 2010

Copy link
Copy Markdown
Author

hey myron, thanks for your comment. i refactored the example to use rspec's mock methods and it seems to work fine. thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment