Sha256: 0d697ae3fadad4f51fcb97641bfd04b633f323bee91d51dc62620da635a47f90

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 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

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 spec/lib/landable/traffic_spec.rb
landable-1.13.2 spec/lib/landable/traffic_spec.rb