我想做这样的事情:
some_method.should_raise <any kind of exception, I don't care>
我应该怎么做?
some_method.should_raise exception
... 不起作用。
最佳答案
expect { some_method }.to raise_error
RSpec 1 语法:
lambda { some_method }.should raise_error
参见 the documentation (对于 RSpec 1 语法)和 RSpec 2 documentation了解更多。
关于ruby-on-rails - 如何在任何异常情况下使用 RSpec 的 should_raise?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1722749/