Skip to content

Instantly share code, notes, and snippets.

Created Nov 24, 2011
What would you like to do?
# When doing this:
class SomeError < Exception
def initialize(some, args); end
describe 'bad message' do
it 'raises an exception' do
obj = stub
# 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
Copy link

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