While I develop, I would like to see sinatra app exceptions when running tests, cosider example:
require 'sinatra/base'
class ExceptionWeb < Sinatra::Base
enable :raise_errors
enable :dump_errors
configure do
enable :dump_errors
end
get "/" do
raise "hell"
"ok"
end
def self.bad_method
raise "bad method"
end
end
require 'rack/test'
describe 'The Web interface' do
include Rack::Test::Methods
def app
ExceptionWeb
end
it "should error out" do
get "/"
#puts last_response.errors
#ExceptionWeb.bad_method
#last_response.should be_ok
end
end
Following rspec code shows no exceptions at all, if I uncomment last_response, then I see something is wrong, but I don't see what was wrong.
But calling mad_method
shows me exception.
And adding puts last_response.errors
to every test doesn't look proper.
I tried sinatra config options raise_errors
and dump_errors
but that doesn't help me much.
Any ideas?
Sinatra will behave the way you want it to by default when ENV['RACK_ENV']
is set to 'test'
. Because of the way Sinatra works, you have to make sure this environment variable is set correctly before the interpreter loads the file in which your application is defined (i.e. it checks this when it creates the app class, not on each request.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With