appsignal 2.1.0.beta.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -1
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +14 -15
  5. data/appsignal.gemspec +1 -1
  6. data/lib/appsignal.rb +1 -1
  7. data/lib/appsignal/auth_check.rb +5 -2
  8. data/lib/appsignal/cli/demo.rb +1 -1
  9. data/lib/appsignal/cli/diagnose.rb +1 -1
  10. data/lib/appsignal/cli/install.rb +1 -1
  11. data/lib/appsignal/transaction.rb +2 -1
  12. data/lib/appsignal/version.rb +1 -1
  13. data/spec/lib/appsignal/auth_check_spec.rb +9 -10
  14. data/spec/lib/appsignal/capistrano2_spec.rb +6 -6
  15. data/spec/lib/appsignal/capistrano3_spec.rb +6 -6
  16. data/spec/lib/appsignal/cli/demo_spec.rb +1 -1
  17. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  18. data/spec/lib/appsignal/cli/helpers_spec.rb +2 -2
  19. data/spec/lib/appsignal/cli/install_spec.rb +2 -2
  20. data/spec/lib/appsignal/cli_spec.rb +2 -2
  21. data/spec/lib/appsignal/config_spec.rb +24 -24
  22. data/spec/lib/appsignal/demo_spec.rb +4 -2
  23. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +11 -7
  24. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +2 -2
  25. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +2 -2
  26. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +1 -1
  27. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +2 -2
  28. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +9 -9
  29. data/spec/lib/appsignal/event_formatter_spec.rb +17 -17
  30. data/spec/lib/appsignal/extension_spec.rb +7 -7
  31. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +0 -3
  32. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +11 -3
  33. data/spec/lib/appsignal/hooks/celluloid_spec.rb +12 -4
  34. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +12 -4
  35. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +21 -13
  36. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +14 -6
  37. data/spec/lib/appsignal/hooks/net_http_spec.rb +11 -3
  38. data/spec/lib/appsignal/hooks/passenger_spec.rb +14 -6
  39. data/spec/lib/appsignal/hooks/puma_spec.rb +18 -10
  40. data/spec/lib/appsignal/hooks/rake_spec.rb +2 -2
  41. data/spec/lib/appsignal/hooks/redis_spec.rb +40 -30
  42. data/spec/lib/appsignal/hooks/sequel_spec.rb +11 -3
  43. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +15 -7
  44. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +17 -9
  45. data/spec/lib/appsignal/hooks/unicorn_spec.rb +16 -8
  46. data/spec/lib/appsignal/hooks/webmachine_spec.rb +14 -4
  47. data/spec/lib/appsignal/hooks_spec.rb +28 -28
  48. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +1 -1
  49. data/spec/lib/appsignal/integrations/grape_spec.rb +3 -3
  50. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +14 -16
  51. data/spec/lib/appsignal/integrations/object_spec.rb +10 -10
  52. data/spec/lib/appsignal/integrations/padrino_spec.rb +14 -18
  53. data/spec/lib/appsignal/integrations/railtie_spec.rb +35 -19
  54. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +2 -2
  55. data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
  56. data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
  57. data/spec/lib/appsignal/integrations/webmachine_spec.rb +1 -1
  58. data/spec/lib/appsignal/js_exception_transaction_spec.rb +1 -1
  59. data/spec/lib/appsignal/minutely_spec.rb +3 -3
  60. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +12 -12
  61. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +2 -2
  62. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +19 -15
  63. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
  64. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +5 -5
  65. data/spec/lib/appsignal/system_spec.rb +5 -5
  66. data/spec/lib/appsignal/transaction_spec.rb +176 -155
  67. data/spec/lib/appsignal/transmitter_spec.rb +29 -23
  68. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +49 -35
  69. data/spec/lib/appsignal/utils_spec.rb +15 -8
  70. data/spec/lib/appsignal_spec.rb +134 -150
  71. data/spec/spec_helper.rb +5 -2
  72. metadata +6 -10
  73. data/spec/lib/tmp/config/appsignal.yml +0 -2
  74. data/spec/support/delegate_matcher.rb +0 -38
@@ -23,7 +23,7 @@ describe Object do
23
23
 
24
24
  context "with anonymous class" do
25
25
  it "instruments the method and calls it" do
26
- expect(Appsignal.active?).to be_true
26
+ expect(Appsignal.active?).to be_truthy
27
27
  expect(transaction).to receive(:start_event)
28
28
  expect(transaction).to receive(:finish_event).with \
29
29
  "foo.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -44,7 +44,7 @@ describe Object do
44
44
  let(:klass) { NamedClass }
45
45
 
46
46
  it "instruments the method and calls it" do
47
- expect(Appsignal.active?).to be_true
47
+ expect(Appsignal.active?).to be_truthy
48
48
  expect(transaction).to receive(:start_event)
49
49
  expect(transaction).to receive(:finish_event).with \
50
50
  "foo.NamedClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -69,7 +69,7 @@ describe Object do
69
69
  let(:klass) { MyModule::NestedModule::NamedClass }
70
70
 
71
71
  it "instruments the method and calls it" do
72
- expect(Appsignal.active?).to be_true
72
+ expect(Appsignal.active?).to be_truthy
73
73
  expect(transaction).to receive(:start_event)
74
74
  expect(transaction).to receive(:finish_event).with \
75
75
  "bar.NamedClass.NestedModule.MyModule.other", nil, nil,
@@ -89,7 +89,7 @@ describe Object do
89
89
  end
90
90
 
91
91
  it "instruments with custom name" do
92
- expect(Appsignal.active?).to be_true
92
+ expect(Appsignal.active?).to be_truthy
93
93
  expect(transaction).to receive(:start_event)
94
94
  expect(transaction).to receive(:finish_event).with \
95
95
  "my_method.group", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -117,7 +117,7 @@ describe Object do
117
117
  let(:transaction) { Appsignal::Transaction.current }
118
118
 
119
119
  it "should not instrument, but still call the method" do
120
- expect(Appsignal.active?).to be_false
120
+ expect(Appsignal.active?).to be_falsy
121
121
  expect(transaction).to_not receive(:start_event)
122
122
  expect(instance.foo).to eq(1)
123
123
  end
@@ -145,7 +145,7 @@ describe Object do
145
145
 
146
146
  context "with anonymous class" do
147
147
  it "instruments the method and calls it" do
148
- expect(Appsignal.active?).to be_true
148
+ expect(Appsignal.active?).to be_truthy
149
149
  expect(transaction).to receive(:start_event)
150
150
  expect(transaction).to receive(:finish_event).with \
151
151
  "bar.class_method.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -166,7 +166,7 @@ describe Object do
166
166
  let(:klass) { NamedClass }
167
167
 
168
168
  it "instruments the method and calls it" do
169
- expect(Appsignal.active?).to be_true
169
+ expect(Appsignal.active?).to be_truthy
170
170
  expect(transaction).to receive(:start_event)
171
171
  expect(transaction).to receive(:finish_event).with \
172
172
  "bar.class_method.NamedClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -190,7 +190,7 @@ describe Object do
190
190
  let(:klass) { MyModule::NestedModule::NamedClass }
191
191
 
192
192
  it "instruments the method and calls it" do
193
- expect(Appsignal.active?).to be_true
193
+ expect(Appsignal.active?).to be_truthy
194
194
  expect(transaction).to receive(:start_event)
195
195
  expect(transaction).to receive(:finish_event).with \
196
196
  "bar.class_method.NamedClass.NestedModule.MyModule.other", nil, nil,
@@ -211,7 +211,7 @@ describe Object do
211
211
  end
212
212
 
213
213
  it "instruments with custom name" do
214
- expect(Appsignal.active?).to be_true
214
+ expect(Appsignal.active?).to be_truthy
215
215
  expect(transaction).to receive(:start_event)
216
216
  expect(transaction).to receive(:finish_event).with \
217
217
  "my_method.group", nil, nil, Appsignal::EventFormatter::DEFAULT
@@ -239,7 +239,7 @@ describe Object do
239
239
  let(:transaction) { Appsignal::Transaction.current }
240
240
 
241
241
  it "should not instrument, but still call the method" do
242
- expect(Appsignal.active?).to be_false
242
+ expect(Appsignal.active?).to be_falsy
243
243
  expect(transaction).to_not receive(:start_event)
244
244
  expect(klass.bar).to eq(2)
245
245
  end
@@ -7,11 +7,9 @@ if DependencyHelper.padrino_present?
7
7
  end
8
8
 
9
9
  before do
10
- Appsignal.stub(
11
- :active? => true,
12
- :start => true,
13
- :start_logger => true
14
- )
10
+ allow(Appsignal).to receive(:active?).and_return(true)
11
+ allow(Appsignal).to receive(:start).and_return(true)
12
+ allow(Appsignal).to receive(:start_logger).and_return(true)
15
13
  end
16
14
 
17
15
  describe "Appsignal::Integrations::PadrinoPlugin" do
@@ -24,7 +22,7 @@ if DependencyHelper.padrino_present?
24
22
  end
25
23
 
26
24
  context "when not active" do
27
- before { Appsignal.stub(:active? => false) }
25
+ before { allow(Appsignal).to receive(:active?).and_return(false) }
28
26
 
29
27
  it "should not add the Listener middleware to the stack" do
30
28
  expect(Padrino).to_not receive(:use)
@@ -76,13 +74,11 @@ if DependencyHelper.padrino_present?
76
74
  end
77
75
 
78
76
  before do
79
- router.stub(
80
- :route_without_appsignal => true,
81
- :request => request,
82
- :env => env,
83
- :settings => settings,
84
- :get_payload_action => "controller#action"
85
- )
77
+ allow(router).to receive(:route_without_appsignal).and_return(true)
78
+ allow(router).to receive(:request).and_return(request)
79
+ allow(router).to receive(:env).and_return(env)
80
+ allow(router).to receive(:settings).and_return(settings)
81
+ allow(router).to receive(:get_payload_action).and_return("controller#action")
86
82
  end
87
83
 
88
84
  context "when Sinatra tells us it's a static file" do
@@ -100,7 +96,7 @@ if DependencyHelper.padrino_present?
100
96
  end
101
97
 
102
98
  context "when appsignal is not active" do
103
- before { Appsignal.stub(:active? => false) }
99
+ before { allow(Appsignal).to receive(:active?).and_return(false) }
104
100
 
105
101
  it "should call the original method" do
106
102
  expect(router).to receive(:route_without_appsignal)
@@ -123,7 +119,7 @@ if DependencyHelper.padrino_present?
123
119
  :set_error => nil
124
120
  )
125
121
  end
126
- before { Appsignal::Transaction.stub(:create => transaction) }
122
+ before { allow(Appsignal::Transaction).to receive(:create).and_return(transaction) }
127
123
 
128
124
  context "without an error" do
129
125
  it "should create a transaction" do
@@ -155,7 +151,7 @@ if DependencyHelper.padrino_present?
155
151
 
156
152
  context "with an error" do
157
153
  let(:error) { VerySpecificError.new }
158
- before { router.stub(:route_without_appsignal).and_raise(error) }
154
+ before { allow(router).to receive(:route_without_appsignal).and_raise(error) }
159
155
 
160
156
  it "should add the exception to the current transaction" do
161
157
  expect(transaction).to receive(:set_error).with(error)
@@ -167,7 +163,7 @@ if DependencyHelper.padrino_present?
167
163
  end
168
164
 
169
165
  describe "#get_payload_action" do
170
- before { router.stub(:settings => settings) }
166
+ before { allow(router).to receive(:settings).and_return(settings) }
171
167
 
172
168
  context "when request is nil" do
173
169
  it "should return the site" do
@@ -194,7 +190,7 @@ if DependencyHelper.padrino_present?
194
190
  context "when request has a route object" do
195
191
  let(:request) { double }
196
192
  let(:route_object) { double(:original_path => "/accounts/edit/:id") }
197
- before { request.stub(:route_obj => route_object) }
193
+ before { allow(request).to receive(:route_obj).and_return(route_object) }
198
194
 
199
195
  it "should return the original path" do
200
196
  expect(router.get_payload_action(request)).to eql("TestApp:/accounts/edit/:id")
@@ -11,42 +11,58 @@ if DependencyHelper.rails_present?
11
11
 
12
12
  describe "#initialize_appsignal" do
13
13
  let(:app) { MyApp::Application }
14
- before { app.middleware.stub(:insert_before => true) }
14
+ before { allow(app.middleware).to receive(:insert_before).and_return(true) }
15
15
 
16
- context "logger" do
16
+ describe ".logger" do
17
17
  before { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
18
18
  subject { Appsignal.logger }
19
19
 
20
- it { should be_a Logger }
20
+ it { is_expected.to be_a Logger }
21
21
  end
22
22
 
23
- context "config" do
24
- subject { Appsignal.config }
25
- context "basics" do
23
+ describe ".config" do
24
+ let(:config) { Appsignal.config }
25
+
26
+ describe "basic configuration" do
26
27
  before { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
27
28
 
28
- it { should be_a(Appsignal::Config) }
29
+ it { expect(config).to be_a(Appsignal::Config) }
29
30
 
30
- its(:root_path) { should eq Pathname.new(project_fixture_path) }
31
- its(:env) { should eq "test" }
32
- its([:name]) { should eq "TestApp" }
33
- its([:log_path]) { should eq Pathname.new(File.join(project_fixture_path, "log")) }
34
- end
31
+ it "sets the root_path" do
32
+ expect(config.root_path).to eq Pathname.new(project_fixture_path)
33
+ end
35
34
 
36
- context "initial config" do
37
- before { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
38
- subject { Appsignal.config.initial_config }
35
+ it "sets the detected environment" do
36
+ expect(config.env).to eq "test"
37
+ end
38
+
39
+ it "loads the app name" do
40
+ expect(config[:name]).to eq "TestApp"
41
+ end
39
42
 
40
- its([:name]) { should eq "MyApp" }
43
+ it "sets the log_path based on the root_path" do
44
+ expect(config[:log_path]).to eq Pathname.new(File.join(project_fixture_path, "log"))
45
+ end
41
46
  end
42
47
 
43
48
  context "with APPSIGNAL_APP_ENV ENV var set" do
44
49
  before do
45
- ENV.should_receive(:fetch).with("APPSIGNAL_APP_ENV", "test").and_return("env_test")
50
+ ENV["APPSIGNAL_APP_ENV"] = "env_test"
46
51
  Appsignal::Integrations::Railtie.initialize_appsignal(app)
47
52
  end
48
53
 
49
- its(:env) { should eq "env_test" }
54
+ it "uses the environment variable value as the environment" do
55
+ expect(config.env).to eq "env_test"
56
+ end
57
+ end
58
+ end
59
+
60
+ describe ".initial_config" do
61
+ before { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
62
+ let(:config) { Appsignal.config.initial_config }
63
+
64
+ it "returns the initial config" do
65
+ expect(config[:name]).to eq "MyApp"
50
66
  end
51
67
  end
52
68
 
@@ -69,7 +85,7 @@ if DependencyHelper.rails_present?
69
85
  end
70
86
 
71
87
  before do
72
- Appsignal.stub(:config => config)
88
+ allow(Appsignal).to receive(:config).and_return(config)
73
89
  end
74
90
 
75
91
  it "should have added the listener and JSExceptionCatcher middleware" do
@@ -16,11 +16,11 @@ if DependencyHelper.resque_present? && DependencyHelper.active_job_present?
16
16
  end
17
17
 
18
18
  describe :around_perform_plugin do
19
- before { SecureRandom.stub(:uuid => 123) }
19
+ before { allow(SecureRandom).to receive(:uuid).and_return(123) }
20
20
  let(:job) { TestActiveJob.new("moo") }
21
21
 
22
22
  it "should wrap in a transaction with the correct params" do
23
- Appsignal.should_receive(:monitor_single_transaction).with(
23
+ expect(Appsignal).to receive(:monitor_single_transaction).with(
24
24
  "perform_job.resque",
25
25
  :class => "TestActiveJob",
26
26
  :method => "perform",
@@ -27,18 +27,18 @@ if DependencyHelper.resque_present?
27
27
  let(:transaction) { Appsignal::Transaction.new("1", "background", {}, {}) }
28
28
  let(:job) { ::Resque::Job.new("default", "class" => "TestJob") }
29
29
  before do
30
- transaction.stub(:complete => true)
31
- Appsignal::Transaction.stub(:current => transaction)
32
- Appsignal.should_receive(:stop)
30
+ allow(transaction).to receive(:complete).and_return(true)
31
+ allow(Appsignal::Transaction).to receive(:current).and_return(transaction)
32
+ expect(Appsignal).to receive(:stop)
33
33
  end
34
34
 
35
35
  context "without exception" do
36
36
  it "should create a new transaction" do
37
- Appsignal::Transaction.should_receive(:create).and_return(transaction)
37
+ expect(Appsignal::Transaction).to receive(:create).and_return(transaction)
38
38
  end
39
39
 
40
40
  it "should wrap in a transaction with the correct params" do
41
- Appsignal.should_receive(:monitor_transaction).with(
41
+ expect(Appsignal).to receive(:monitor_transaction).with(
42
42
  "perform_job.resque",
43
43
  :class => "TestJob",
44
44
  :method => "perform"
@@ -46,7 +46,7 @@ if DependencyHelper.resque_present?
46
46
  end
47
47
 
48
48
  it "should close the transaction" do
49
- transaction.should_receive(:complete)
49
+ expect(transaction).to receive(:complete)
50
50
  end
51
51
 
52
52
  after { job.perform }
@@ -56,7 +56,7 @@ if DependencyHelper.resque_present?
56
56
  let(:job) { ::Resque::Job.new("default", "class" => "BrokenTestJob") }
57
57
 
58
58
  it "should set the exception" do
59
- Appsignal::Transaction.any_instance.should_receive(:set_error)
59
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_error)
60
60
  end
61
61
 
62
62
  after do
@@ -71,7 +71,7 @@ if DependencyHelper.resque_present?
71
71
  end
72
72
 
73
73
  context "without resque" do
74
- before(:all) { Object.send(:remove_const, :Resque) }
74
+ before(:context) { Object.send(:remove_const, :Resque) }
75
75
 
76
76
  specify { expect { ::Resque }.to raise_error(NameError) }
77
77
  specify { expect { load file }.to_not raise_error }
@@ -6,12 +6,12 @@ if DependencyHelper.sinatra_present?
6
6
  context "Appsignal.logger" do
7
7
  subject { Appsignal.logger }
8
8
 
9
- it { should be_a Logger }
9
+ it { is_expected.to be_a Logger }
10
10
  end
11
11
 
12
12
  describe "middleware" do
13
13
  it "adds the instrumentation middleware to Sinatra::Base" do
14
- Sinatra::Base.middleware.to_a.should include(
14
+ expect(Sinatra::Base.middleware.to_a).to include(
15
15
  [Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
16
16
  )
17
17
  end
@@ -9,7 +9,7 @@ if DependencyHelper.webmachine_present?
9
9
  let(:response) { double }
10
10
  let(:transaction) { double(:set_action => true) }
11
11
  let(:fsm) { Webmachine::Decision::FSM.new(resource, request, response) }
12
- before(:all) { start_agent }
12
+ before(:context) { start_agent }
13
13
 
14
14
  # Make sure the request responds to the method we need to get query params.
15
15
  describe "request" do
@@ -1,5 +1,5 @@
1
1
  describe Appsignal::JSExceptionTransaction do
2
- before { SecureRandom.stub(:uuid => "123abc") }
2
+ before { allow(SecureRandom).to receive(:uuid).and_return("123abc") }
3
3
 
4
4
  let!(:transaction) { Appsignal::JSExceptionTransaction.new(data) }
5
5
  let(:data) do
@@ -12,7 +12,7 @@ describe Appsignal::Minutely do
12
12
  probe = double
13
13
  expect(probe).to receive(:call).at_least(:twice)
14
14
  Appsignal::Minutely.probes << probe
15
- Appsignal::Minutely.stub(:wait_time => 0.1)
15
+ allow(Appsignal::Minutely).to receive(:wait_time).and_return(0.1)
16
16
 
17
17
  Appsignal::Minutely.start
18
18
 
@@ -22,7 +22,7 @@ describe Appsignal::Minutely do
22
22
 
23
23
  describe ".wait_time" do
24
24
  it "should get the time to the next minute" do
25
- Time.any_instance.stub(:sec => 30)
25
+ allow_any_instance_of(Time).to receive(:sec).and_return(30)
26
26
  expect(Appsignal::Minutely.wait_time).to eq 30
27
27
  end
28
28
  end
@@ -33,7 +33,7 @@ describe Appsignal::Minutely do
33
33
 
34
34
  Appsignal::Minutely.add_gc_probe
35
35
 
36
- expect(Appsignal::Minutely.probes).to have(1).item
36
+ expect(Appsignal::Minutely.probes.size).to eq(1)
37
37
  expect(Appsignal::Minutely.probes[0]).to be_instance_of(Appsignal::Minutely::GCProbe)
38
38
  end
39
39
  end
@@ -1,5 +1,5 @@
1
1
  describe Appsignal::Rack::GenericInstrumentation do
2
- before :all do
2
+ before :context do
3
3
  start_agent
4
4
  end
5
5
 
@@ -10,11 +10,11 @@ describe Appsignal::Rack::GenericInstrumentation do
10
10
 
11
11
  describe "#call" do
12
12
  before do
13
- middleware.stub(:raw_payload => {})
13
+ allow(middleware).to receive(:raw_payload).and_return({})
14
14
  end
15
15
 
16
16
  context "when appsignal is active" do
17
- before { Appsignal.stub(:active? => true) }
17
+ before { allow(Appsignal).to receive(:active?).and_return(true) }
18
18
 
19
19
  it "should call with monitoring" do
20
20
  expect(middleware).to receive(:call_with_appsignal_monitoring).with(env)
@@ -22,7 +22,7 @@ describe Appsignal::Rack::GenericInstrumentation do
22
22
  end
23
23
 
24
24
  context "when appsignal is not active" do
25
- before { Appsignal.stub(:active? => false) }
25
+ before { allow(Appsignal).to receive(:active?).and_return(false) }
26
26
 
27
27
  it "should not call with monitoring" do
28
28
  expect(middleware).to_not receive(:call_with_appsignal_monitoring)
@@ -38,7 +38,7 @@ describe Appsignal::Rack::GenericInstrumentation do
38
38
 
39
39
  describe "#call_with_appsignal_monitoring" do
40
40
  it "should create a transaction" do
41
- Appsignal::Transaction.should_receive(:create).with(
41
+ expect(Appsignal::Transaction).to receive(:create).with(
42
42
  kind_of(String),
43
43
  Appsignal::Transaction::HTTP_REQUEST,
44
44
  kind_of(Rack::Request)
@@ -46,24 +46,24 @@ describe Appsignal::Rack::GenericInstrumentation do
46
46
  end
47
47
 
48
48
  it "should call the app" do
49
- app.should_receive(:call).with(env)
49
+ expect(app).to receive(:call).with(env)
50
50
  end
51
51
 
52
52
  context "with an error" do
53
53
  let(:error) { VerySpecificError.new }
54
54
  let(:app) do
55
55
  double.tap do |d|
56
- d.stub(:call).and_raise(error)
56
+ allow(d).to receive(:call).and_raise(error)
57
57
  end
58
58
  end
59
59
 
60
60
  it "should set the error" do
61
- Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
61
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_error).with(error)
62
62
  end
63
63
  end
64
64
 
65
65
  it "should set the action to unknown" do
66
- Appsignal::Transaction.any_instance.should_receive(:set_action).with("unknown")
66
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_action).with("unknown")
67
67
  end
68
68
 
69
69
  context "with a route specified in the env" do
@@ -72,16 +72,16 @@ describe Appsignal::Rack::GenericInstrumentation do
72
72
  end
73
73
 
74
74
  it "should set the action" do
75
- Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /")
75
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_action).with("GET /")
76
76
  end
77
77
  end
78
78
 
79
79
  it "should set metadata" do
80
- Appsignal::Transaction.any_instance.should_receive(:set_metadata).twice
80
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_metadata).twice
81
81
  end
82
82
 
83
83
  it "should set the queue start" do
84
- Appsignal::Transaction.any_instance.should_receive(:set_http_or_background_queue_start)
84
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_http_or_background_queue_start)
85
85
  end
86
86
 
87
87
  after { middleware.call(env) rescue VerySpecificError }