Hi all
Long time since I've posted to rspec-users. Glad to see the place is still here
and hope you're all well :-)
I have a question about ignoring exceptions when they're not interesting. For
example, I have a few cases in my code along these lines…
it "prints an error" do
expect {
run_command(%w[ missing_wallet.dat ])
}.to raise_error
stream_bundle.captured_error.should eq "Couldn't find wallet file:
missing_wallet.dat\n"
end
it "raises a CLI::CommandError" do
expect {
run_command(%w[ missing_wallet.dat ])
}.to raise_error(CLI::CommandError)
end
But in the first example, I'm only bothered about the output, not the error. So
I was thinking of writing something along the lines of:
it "prints an error" do
ignoring_errors {
run_command(%w[ missing_wallet.dat ])
}
stream_bundle.captured_error.should eq "Couldn't find wallet file:
missing_wallet.dat\n"
end
Now obviously that wouldn't be hard to add as a helper method. But it got me
thinking…
* Do any of you do this?
* Does RSpec already let you somehow?
* Is it a useful convention?
* Is it hiding anything else? (I don't use exceptions much, so I may be abusing
them.)
Cheers
Ash
--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashmoran
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users