Sha256: 204d6d88640d460ca10256e4db92c7e283b40f5f20b92337a475f70541dc23d9
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
require "spec_helper" describe Teaspoon::ExceptionHandling do subject { Teaspoon::ExceptionHandling } before do @orig_debug = Rails.application.config.assets.debug @orig_show_exceptions = Rails.application.config.action_dispatch.show_exceptions end after do Rails.application.config.assets.debug = @orig_debug Rails.application.config.action_dispatch.show_exceptions = @orig_show_exceptions end describe ".add_rails_handling" do before do allow(subject).to receive(:render_exceptions_with_javascript) end it "sets config.assets.debug to false" do subject.add_rails_handling expect(Rails.application.config.assets.debug).to be_falsey end it "sets config.action_dispatch.show_exceptions to true" do subject.add_rails_handling expect(Rails.application.config.action_dispatch.show_exceptions).to be_truthy end it "calls #render_exceptions_with_javascript" do expect(subject).to receive(:render_exceptions_with_javascript) subject.add_rails_handling end end describe "ActionDispatch::DebugExceptions#render_exception mixin" do before do subject.add_rails_handling end let(:middleware) { ActionDispatch::DebugExceptions.new(app, nil) } let(:app) { double(:app) } let(:env) { double(:env, "[]" => []) } it "responds with a javascript tag that raises the error" do response = middleware.send(:render_exception, env, Exception.new("_message_")) expect(response).to eq([200, {"Content-Type"=>"text/html;", "Content-Length"=>"54"}, ["<script>throw Error(\"Exception: _message_\\n\")</script>"]]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
teaspoon-0.9.1 | spec/teaspoon/exceptions_spec.rb |
teaspoon-0.9.0 | spec/teaspoon/exceptions_spec.rb |