Is it somehow possible to test warnings i Ruby using RSpec?
Like this:
class MyClass
def initialize
warn \"Something is wrong\"
end
end
it \
There is a good article with custom expectation which solves exactly your problem: http://greyblake.com/blog/2012/12/14/custom-expectations-with-rspec/
So it would like:
expect { MyClass.new }.to write("Something is wrong").to(:error)
Base on that article you can create you own expectation to use it like this:
expect { MyClass.new }.to warn("Something is wrong")