How to write expect {}.to raise_error when rspec's syntax is configured with only should
rspec, ruby, syntax, testing
Solution
I would suggest to use this only if the most-recent RSpec `expect { code() }.to raise_error` syntax is not available to you:
lambda { foo( :bad_param ) }.should raise_error
or
lambda { foo( :bad_param ) }.should raise_error( ArgumentError )
Replacing `foo( :bad_param )` with whatever Ruby code you wish to assert fails, and `ArgumentError` with whatever exception class you expect the failure to raise.
Problem
I have this configuration on rspec: ``` config.expect_with :rspec do |c| c.syntax = :should end ``` It makes the `expect {}.to raise_error` invalid, how could I write this error raising test with should syntax?