Skip to content

Instantly share code, notes, and snippets.

@kyamaguchi
Created August 1, 2012 15:06
Show Gist options
  • Select an option

  • Save kyamaguchi/3227620 to your computer and use it in GitHub Desktop.

Select an option

Save kyamaguchi/3227620 to your computer and use it in GitHub Desktop.
RSpec stub
# Default
Hoge.any_instance.stub(:save).and_return(false)
Hoge.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
# mocha
Hoge.any_instance.stubs(:save).returns(false)
Hoge.any_instance.expects(:update_attributes).with({'these' => 'params'})
# spec_helper for mocha
RSpec.configure do |config|
config.mock_with :mocha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment