Sha256: b76f8bfe5ab2261f671eb4d27da51c28beba90f96ff2868e5cae89b74714665a

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'rack/test'

describe 'Rescue from within a Rails 3.x controller' do
  include RSpec::Rails::RequestExampleGroup
  include Rack::Test::Methods

  it 'is testing tails 3.x' do
    Rails.version.should =~ /^3\./
  end

  describe 'dummy app' do
    it 'should response nicely to index' do
      get '/'
      last_response.should be_ok
      last_response.body.should == 'Works fine here'
    end
  end

  it 'should intercept error and notify crashlog' do
    CrashLog.should_receive(:notify).with(kind_of(RuntimeError)).once

    begin
      get '/broken'
      last_response.status.should == 500
      last_response.body.should match /We're sorry, but something went wrong/
    rescue
    end

  end

  it 'should capture current user'
  it 'should capture crash log custom data'

  it 'should raise error again after notifying' do
    ENV['RAILS_ENV']='production'

    logger = stub("Logger")
    ActionDispatch::DebugExceptions.any_instance.stub(:logger).and_return(logger)
    logger.should_receive(:fatal).once

    begin
      get '/broken'
      last_response.status.should == 500
    rescue
    end
  end

  it 'should be able to defer reporting to another thread'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crashlog-1.0.0.rc1 spec/requests/rails_controller_rescue_spec.rb