Sha256: 1d1801faf5cb71607abdd2f2b91e31450ea18129e766d355719c3b10bbaf7276
Contents?: true
Size: 1.88 KB
Versions: 12
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe "ResquePlugin" 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 instrument with correct params" do ActiveSupport::Notifications.should_receive(:instrument).with( 'perform_job.resque', :class => 'Resque::Job', :method => 'perform' ) end it "should close the transaction" do transaction.should_receive(:complete!) end after { job.around_perform_resque_plugin { invoked_job } } end context "with exception" do it "should set the exception" do transaction.should_receive(:add_exception) 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
12 entries across 12 versions & 1 rubygems