Sha256: 8765732cf9451c28f25fbc615ddcf4c96875f221895861bc3bd1aaa344dc8d90

Contents?: true

Size: 951 Bytes

Versions: 16

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'
 
module Landable

  class TrackError < StandardError
  end

  class SaveError < StandardError
  end
 
describe Traffic, type: :controller do
 
  controller(ApplicationController) do
    include Landable::Traffic
    prepend_around_action :track_with_landable!

    def my_method
      render nothing: true
    end
  end
  
  before do
   routes.draw do
     get 'my_method' => 'anonymous#my_method'
   end
  end
 
  describe 'track_with_landable!' do
   it 'should log errors' do
    tracker = double('tracker')

    Landable::Traffic::Tracker.stub(:for).and_return(tracker)
    tracker.stub(:track).and_raise(TrackError)
    tracker.stub(:save).and_raise(SaveError)

    controller.should_receive(:newrelic_notice_error) { |error| error.should be_an_instance_of TrackError }
    controller.should_receive(:newrelic_notice_error) { |error| error.should be_an_instance_of SaveError }

    get :my_method
   end
  end
 
 end
 
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 spec/lib/landable/traffic_spec.rb
landable-1.12.3 spec/lib/landable/traffic_spec.rb
landable-1.12.2 spec/lib/landable/traffic_spec.rb
landable-1.12.1 spec/lib/landable/traffic_spec.rb
landable-1.11.1 spec/lib/landable/traffic_spec.rb
landable-1.11.0 spec/lib/landable/traffic_spec.rb
landable-1.10.0.rc2 spec/lib/landable/traffic_spec.rb
landable-1.10.0.rc1 spec/lib/landable/traffic_spec.rb
landable-1.9.2 spec/lib/landable/traffic_spec.rb
landable-1.9.1 spec/lib/landable/traffic_spec.rb
landable-1.9.0 spec/lib/landable/traffic_spec.rb
landable-1.9.0.rc2 spec/lib/landable/traffic_spec.rb
landable-1.9.0.rc1 spec/lib/landable/traffic_spec.rb
landable-1.8.0 spec/lib/landable/traffic_spec.rb
landable-1.7.1.rc1 spec/lib/landable/traffic_spec.rb
landable-1.7.0 spec/lib/landable/traffic_spec.rb