Created
November 24, 2011 20:43
-
-
Save abyx/1392238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?