spec/lib/appsignal/rack/rails_instrumentation_spec.rb in appsignal-2.1.2 vs spec/lib/appsignal/rack/rails_instrumentation_spec.rb in appsignal-2.2.0.beta.1
- old
+ new
@@ -44,32 +44,34 @@
end
after { middleware.call(env) }
end
- describe "#call_with_appsignal_monitoring" do
+ describe "#call_with_appsignal_monitoring", :error => false do
it "should create a transaction" do
expect(Appsignal::Transaction).to receive(:create).with(
"1",
Appsignal::Transaction::HTTP_REQUEST,
kind_of(ActionDispatch::Request),
:params_method => :filtered_parameters
).and_return(
- double(
+ instance_double(
+ "Appsignal::Transaction",
:set_action => nil,
+ :set_action_if_nil => nil,
:set_http_or_background_queue_start => nil,
:set_metadata => nil
)
)
end
it "should call the app" do
expect(app).to receive(:call).with(env)
end
- context "with an error" do
- let(:error) { VerySpecificError.new }
+ context "with an error", :error => true do
+ let(:error) { VerySpecificError }
let(:app) do
double.tap do |d|
allow(d).to receive(:call).and_raise(error)
end
end
@@ -82,14 +84,15 @@
it "should set metadata" do
expect_any_instance_of(Appsignal::Transaction).to receive(:set_metadata).twice
end
it "should set the action and queue start" do
- expect_any_instance_of(Appsignal::Transaction).to receive(:set_action).with("MockController#index")
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_action_if_nil).with("MockController#index")
expect_any_instance_of(Appsignal::Transaction).to receive(:set_http_or_background_queue_start)
end
- after { middleware.call(env) rescue VerySpecificError }
+ after(:error => false) { middleware.call(env) }
+ after(:error => true) { expect { middleware.call(env) }.to raise_error(VerySpecificError) }
end
describe "#request_id" do
subject { middleware.request_id(env) }