Skip to content

Instantly share code, notes, and snippets.

@abyx
Created Nov 24, 2011
Embed
What would you like to do?
# When doing this:
class SomeError < Exception
def initialize(some, args); end
end
describe 'bad message' do
it 'raises an exception' do
obj = stub
obj.should_receive(:dude!).and_raise(SomeError)
obj.dude!
end
end
# We should get a failure, since RSpec can't initialize the exception,
# but I find the error a bit unhelpful:
# 1) bad message raises an exception
# Failure/Error: def initialize(some, args); end
# ArgumentError:
# wrong number of arguments (0 for 2)
# # ./bad_message.rb:2:in `initialize'
# # ./bad_message.rb:6:in `some_method'
# # ./bad_message.rb:13:in `block (2 levels) in <top (required)>'
# (especially in big projects, where you don't see the initialize() definition in the error
@abyx
Copy link
Author

abyx commented Nov 24, 2011

I want to make RSpec display something more meaningful to the user like "Dude, I can't initialize SomeError exception, wanna gimme an instance?"
Should I just make RSpec raise some new exception class that says this?

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