spec/lib/appsignal/hooks/sidekiq_spec.rb in appsignal-2.1.0.beta.1 vs spec/lib/appsignal/hooks/sidekiq_spec.rb in appsignal-2.1.0
- old
+ new
@@ -13,17 +13,17 @@
}
end
let(:plugin) { Appsignal::Hooks::SidekiqPlugin.new }
before do
- Appsignal::Transaction.stub(:current => current_transaction)
+ allow(Appsignal::Transaction).to receive(:current).and_return(current_transaction)
start_agent
end
context "with a performance call" do
it "should wrap in a transaction with the correct params" do
- Appsignal.should_receive(:monitor_transaction).with(
+ expect(Appsignal).to receive(:monitor_transaction).with(
"perform_job.sidekiq",
:class => "TestClass",
:method => "perform",
:metadata => {
"retry_count" => "0",
@@ -54,11 +54,11 @@
"enqueued_at" => Time.parse("01-01-2001 10:00:00UTC").to_f
}
end
it "should wrap in a transaction with the correct params" do
- Appsignal.should_receive(:monitor_transaction).with(
+ expect(Appsignal).to receive(:monitor_transaction).with(
"perform_job.sidekiq",
:class => "TestClass",
:method => "perform",
:metadata => {
"queue" => "default"
@@ -81,11 +81,11 @@
context "with an erroring call" do
let(:error) { VerySpecificError.new }
it "should add the exception to appsignal" do
- Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_error).with(error)
end
after do
begin
Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
@@ -105,28 +105,36 @@
"class" => "TestClass"
}
end
it "should only add items to the hash that do not appear in JOB_KEYS" do
- plugin.formatted_metadata(item).should eq("foo" => "bar")
+ expect(plugin.formatted_metadata(item)).to eq("foo" => "bar")
end
end
end
describe Appsignal::Hooks::SidekiqHook do
context "with sidekiq" do
- before :all do
+ before :context do
module Sidekiq
def self.configure_server
end
end
Appsignal::Hooks::SidekiqHook.new.install
end
- after(:all) { Object.send(:remove_const, :Sidekiq) }
+ after(:context) { Object.send(:remove_const, :Sidekiq) }
- its(:dependencies_present?) { should be_true }
+ describe "#dependencies_present?" do
+ subject { described_class.new.dependencies_present? }
+
+ it { is_expected.to be_truthy }
+ end
end
context "without sidekiq" do
- its(:dependencies_present?) { should be_false }
+ describe "#dependencies_present?" do
+ subject { described_class.new.dependencies_present? }
+
+ it { is_expected.to be_falsy }
+ end
end
end