Sha256: a53ad6a33e17d7787eb9638a81be3d9cebc6fff254c80d0555ba2525febf0081

Contents?: true

Size: 1.91 KB

Versions: 31

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe "Resque integration" do
  let(:file) { File.expand_path('lib/appsignal/integrations/resque.rb') }

  context "with resque" do
    before do
      module Resque

        def self.before_first_fork
        end

        def self.after_fork
        end

        class Job
        end

        class TestError < StandardError
        end
      end

      load file
      start_agent
    end

    describe :around_perform_resque_plugin do
      let(:transaction) { Appsignal::Transaction.new('1', {}) }
      let(:job) { Resque::Job }
      let(:invoked_job) { nil }
      before do
        transaction.stub(:complete! => true)
        Appsignal::Transaction.stub(:current => transaction)
      end

      context "without exception" do
        it "should create a new transaction" do
          Appsignal::Transaction.should_receive(:create).and_return(transaction)
        end

        it "should wrap in a transaction with the correct params" do
          Appsignal.should_receive(:monitor_transaction).with(
            'perform_job.resque',
            :class => 'Resque::Job',
            :method => 'perform'
          )
        end

        it "should close the transaction" do
          Appsignal::Transaction.should_receive(:complete_current!)
        end

        after { job.around_perform_resque_plugin { invoked_job }  }
      end

      context "with exception" do
        it "should set the exception" do
          transaction.should_receive(:set_error)
        end

        after do
          begin
            job.around_perform_resque_plugin { raise(Resque::TestError.new('the roof')) }
          rescue Resque::TestError
            # Do nothing
          end
        end
      end
    end
  end

  context "without resque" do
    before(:all) { Object.send(:remove_const, :Resque) }

    specify { expect { ::Resque }.to raise_error(NameError) }
    specify { expect { load file }.to_not raise_error }
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
appsignal-0.12.beta.31 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.30 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.29 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.28 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.27 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.26 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.25 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.24 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.23 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.22 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.21 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.20 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.19 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.18 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.17 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.16 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.15 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.14 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.13 spec/lib/appsignal/integrations/resque_spec.rb
appsignal-0.12.beta.12 spec/lib/appsignal/integrations/resque_spec.rb