Skip to content

Instantly share code, notes, and snippets.

@jszmajda
Created November 15, 2010 14:17
Show Gist options
  • Save jszmajda/700396 to your computer and use it in GitHub Desktop.
Save jszmajda/700396 to your computer and use it in GitHub Desktop.
how to handle conflicting stubbing requirements
require 'spec_helper'
describe "Bar" do
it "should not bar" do
lambda {
"foo".bar
}.should raise_exception
end
end
require 'spec_helper'
describe "Foo" do
before :all do
# breaks other test: String.any_instance.stubs(:bar).returns("Hey, bar!")
@mystring = "yay"
@mystring.stubs(:bar).returns("Hey, bar!")
end
it "should bar" do
@mystring.bar.should == "Hey, bar!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment