Skip to content

Instantly share code, notes, and snippets.

@jeffrydegrande
Created October 5, 2011 21:40
Show Gist options
  • Save jeffrydegrande/1265825 to your computer and use it in GitHub Desktop.
Save jeffrydegrande/1265825 to your computer and use it in GitHub Desktop.
def destroy
if foo?
disable
else
super
end
end
subject.stub(:foo?).and_return(false)
subject.should_not_receive(:disable)
subject.should_receive ??????????????
subject.destroy
@sobrinho
Copy link

sobrinho commented Oct 5, 2011

Você pode verificar pelo ActiveRecord::Base#destroyed?

# scenario 1
subject.stub(:foo?).and_return(false)
subject.destroy
subject.should_not be_destroyed

# scenario 2
subject.stub(:foo?).and_return(true)
subject.destroy
subject.should be_destroyed

@jeffrydegrande
Copy link
Author

Ta na minha spec_no_rails pasta, isolado do rails

@rafaelss
Copy link

rafaelss commented Oct 5, 2011

subject.should_receive(:disable).never

serve?

@jeffrydegrande
Copy link
Author

acabei fazer isso mesmo. serve sim.

valeu

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