appsignal 2.9.17 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +0 -6
  3. data/CHANGELOG.md +24 -0
  4. data/Rakefile +16 -2
  5. data/ext/agent.yml +19 -19
  6. data/lib/appsignal/cli.rb +9 -2
  7. data/lib/appsignal/cli/diagnose.rb +20 -19
  8. data/lib/appsignal/cli/helpers.rb +22 -10
  9. data/lib/appsignal/cli/install.rb +2 -1
  10. data/lib/appsignal/config.rb +23 -9
  11. data/lib/appsignal/event_formatter.rb +4 -4
  12. data/lib/appsignal/minutely.rb +4 -4
  13. data/lib/appsignal/rack/js_exception_catcher.rb +6 -0
  14. data/lib/appsignal/transaction.rb +1 -1
  15. data/lib/appsignal/version.rb +1 -1
  16. data/spec/lib/appsignal/cli/diagnose_spec.rb +54 -11
  17. data/spec/lib/appsignal/cli/helpers_spec.rb +11 -3
  18. data/spec/lib/appsignal/cli/install_spec.rb +30 -1
  19. data/spec/lib/appsignal/config_spec.rb +78 -7
  20. data/spec/lib/appsignal/hooks/action_cable_spec.rb +1 -5
  21. data/spec/lib/appsignal/hooks/rake_spec.rb +41 -39
  22. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -15
  23. data/spec/lib/appsignal/integrations/object_spec.rb +2 -2
  24. data/spec/lib/appsignal/integrations/que_spec.rb +26 -39
  25. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +108 -46
  26. data/spec/lib/appsignal/integrations/resque_spec.rb +40 -39
  27. data/spec/lib/appsignal/minutely_spec.rb +3 -3
  28. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +19 -5
  29. data/spec/lib/appsignal/transaction_spec.rb +4 -12
  30. data/spec/lib/appsignal_spec.rb +7 -8
  31. data/spec/spec_helper.rb +11 -11
  32. data/spec/support/fixtures/projects/broken/config/appsignal.yml +1 -0
  33. data/spec/support/helpers/cli_helpers.rb +15 -1
  34. data/spec/support/helpers/transaction_helpers.rb +53 -0
  35. data/spec/support/matchers/be_completed.rb +5 -0
  36. data/spec/support/matchers/have_colorized_text.rb +28 -0
  37. data/spec/support/testing.rb +113 -0
  38. metadata +10 -2
@@ -23,9 +23,15 @@ module Appsignal
23
23
  # @see http://docs.appsignal.com/front-end/error-handling.html
24
24
  # @api private
25
25
  class JSExceptionCatcher
26
+ include Appsignal::Utils::DeprecationMessage
27
+
26
28
  def initialize(app, _options = nil)
27
29
  Appsignal.logger.debug \
28
30
  "Initializing Appsignal::Rack::JSExceptionCatcher"
31
+ message = "The Appsignal::Rack::JSExceptionCatcher is deprecated. " \
32
+ "Please use the official AppSignal JavaScript integration instead. " \
33
+ "https://docs.appsignal.com/front-end/"
34
+ deprecation_message message, Appsignal.logger
29
35
  @app = app
30
36
  end
31
37
 
@@ -25,7 +25,7 @@ module Appsignal
25
25
  Thread.current[:appsignal_transaction] = Appsignal::Transaction.new(id, namespace, request, options)
26
26
  else
27
27
  # Otherwise, log the issue about trying to start another transaction
28
- Appsignal.logger.debug "Trying to start new transaction with id " \
28
+ Appsignal.logger.warn "Trying to start new transaction with id " \
29
29
  "'#{id}', but a transaction with id '#{current.transaction_id}' " \
30
30
  "is already running. Using transaction '#{current.transaction_id}'."
31
31
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.9.17".freeze
4
+ VERSION = "2.10.0".freeze
5
5
  end
@@ -2,7 +2,7 @@ require "bundler/cli"
2
2
  require "bundler/cli/common"
3
3
  require "appsignal/cli"
4
4
 
5
- describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_input do
5
+ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_input, :color => false do
6
6
  include CLIHelpers
7
7
 
8
8
  class DiagnosticsReportEndpoint
@@ -24,7 +24,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
24
24
  let(:out_stream) { std_stream }
25
25
  let(:output) { out_stream.read }
26
26
  let(:config) { project_fixture_config }
27
- let(:cli) { described_class }
27
+ let(:cli_class) { described_class }
28
28
  let(:options) { { :environment => config.env } }
29
29
  let(:gem_path) { Bundler::CLI::Common.select_spec("appsignal").full_gem_path.strip }
30
30
  let(:received_report) { DiagnosticsReportEndpoint.received_report }
@@ -34,11 +34,11 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
34
34
  before do
35
35
  # Clear previous reports
36
36
  DiagnosticsReportEndpoint.clear_report!
37
- if cli.instance_variable_defined? :@data
37
+ if cli_class.instance_variable_defined? :@data
38
38
  # Because this is saved on the class rather than an instance of the
39
39
  # class we need to clear it like this in case a certain test doesn't
40
40
  # generate a report.
41
- cli.remove_instance_variable :@data
41
+ cli_class.remove_instance_variable :@data
42
42
  end
43
43
 
44
44
  if DependencyHelper.rails_present?
@@ -54,16 +54,18 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
54
54
  before :api_stub => true do
55
55
  stub_api_request config, "auth"
56
56
  end
57
+ before(:color => false) { options["no-color"] = nil }
58
+ before(:color => true) { options["color"] = nil }
57
59
  before(:send_report => :yes_cli_input) do
58
60
  accept_prompt_to_send_diagnostics_report
59
61
  capture_diagnatics_report_request
60
62
  end
61
63
  before(:send_report => :no_cli_input) { dont_accept_prompt_to_send_diagnostics_report }
62
64
  before(:send_report => :yes_cli_option) do
63
- options[:send_report] = true
65
+ options["send-report"] = nil
64
66
  capture_diagnatics_report_request
65
67
  end
66
- before(:send_report => :no_cli_option) { options[:send_report] = false }
68
+ before(:send_report => :no_cli_option) { options["no-send-report"] = nil }
67
69
  after { Appsignal.config = nil }
68
70
 
69
71
  def capture_diagnatics_report_request
@@ -77,7 +79,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
77
79
  def run_within_dir(chdir)
78
80
  prepare_cli_input
79
81
  Dir.chdir chdir do
80
- capture_stdout(out_stream) { cli.run(options) }
82
+ capture_stdout(out_stream) { run_cli("diagnose", options) }
81
83
  end
82
84
  end
83
85
 
@@ -228,6 +230,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
228
230
 
229
231
  it "outputs extension is not loaded" do
230
232
  expect(output).to include "Extension loaded: false"
233
+ expect(output).to include "Extension is not loaded. No agent report created."
234
+ end
235
+
236
+ context "with color", :color => true do
237
+ it "outputs extension is not loaded in color" do
238
+ expect(output).to have_colorized_text :red,
239
+ " Extension is not loaded. No agent report created."
240
+ end
231
241
  end
232
242
 
233
243
  it "transmits extension_loaded: false in report" do
@@ -682,6 +692,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
682
692
  context "without environment" do
683
693
  let(:config) { project_fixture_config(nil) }
684
694
  let(:options) { {} }
695
+ let(:warning_message) do
696
+ " Warning: No environment set, no config loaded!\n" \
697
+ " Please make sure appsignal diagnose is run within your\n" \
698
+ " project directory with an environment.\n" \
699
+ " appsignal diagnose --environment=production"
700
+ end
685
701
  before do
686
702
  ENV.delete("RAILS_ENV") # From spec_helper
687
703
  ENV.delete("RACK_ENV")
@@ -689,10 +705,15 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
689
705
  end
690
706
 
691
707
  it "outputs a warning that no config is loaded" do
692
- expect(output).to include \
693
- "Environment: \"\"\n",
694
- " Warning: No environment set, no config loaded!",
695
- " appsignal diagnose --environment=production"
708
+ expect(output).to include "Environment: \"\"\n#{warning_message}"
709
+ expect(output).to_not have_color_markers
710
+ end
711
+
712
+ context "with color", :color => true do
713
+ it "outputs a warning that no config is loaded in color" do
714
+ expect(output).to include "Environment: \"\"\n"
715
+ expect(output).to have_colorized_text :red, warning_message
716
+ end
696
717
  end
697
718
 
698
719
  it "outputs config defaults" do
@@ -890,6 +911,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
890
911
  "Validating Push API key: valid"
891
912
  end
892
913
 
914
+ context "with color", :color => true do
915
+ it "outputs valid in color" do
916
+ expect(output).to include "Validation",
917
+ "Validating Push API key: #{colorize("valid", :green)}"
918
+ end
919
+ end
920
+
893
921
  it "transmits validation in report" do
894
922
  expect(received_report).to include(
895
923
  "validation" => {
@@ -910,6 +938,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
910
938
  "Validating Push API key: invalid"
911
939
  end
912
940
 
941
+ context "with color", :color => true do
942
+ it "outputs invalid in color" do
943
+ expect(output).to include "Validation",
944
+ "Validating Push API key: #{colorize("invalid", :red)}"
945
+ end
946
+ end
947
+
913
948
  it "transmits validation in report" do
914
949
  expect(received_report).to include(
915
950
  "validation" => {
@@ -931,6 +966,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
931
966
  %("Could not confirm authorization: 500")
932
967
  end
933
968
 
969
+ context "with color", :color => true do
970
+ it "outputs error in color" do
971
+ expect(output).to include "Validation",
972
+ "Validating Push API key: " +
973
+ colorize(%(Failed with status 500\n"Could not confirm authorization: 500"), :red)
974
+ end
975
+ end
976
+
934
977
  it "transmits validation in report" do
935
978
  expect(received_report).to include(
936
979
  "validation" => {
@@ -24,7 +24,7 @@ describe Appsignal::CLI::Helpers do
24
24
  describe ".colorize" do
25
25
  subject { cli.send(:colorize, "text", :green) }
26
26
 
27
- context "on windows" do
27
+ context "when on windows" do
28
28
  before { allow(Gem).to receive(:win_platform?).and_return(true) }
29
29
 
30
30
  it "outputs plain string" do
@@ -32,11 +32,19 @@ describe Appsignal::CLI::Helpers do
32
32
  end
33
33
  end
34
34
 
35
- context "not on windows" do
35
+ context "when coloring is set to false" do
36
+ before { cli.send(:coloring=, false) }
37
+
38
+ it "outputs plain string" do
39
+ expect(subject).to eq "text"
40
+ end
41
+ end
42
+
43
+ context "when not on windows" do
36
44
  before { allow(Gem).to receive(:win_platform?).and_return(false) }
37
45
 
38
46
  it "wraps text in color tags" do
39
- expect(subject).to eq "\e[32mtext\e[0m"
47
+ expect(subject).to have_colorized_text(:green, "text")
40
48
  end
41
49
  end
42
50
  end
@@ -9,6 +9,7 @@ describe Appsignal::CLI::Install do
9
9
  let(:config) { Appsignal::Config.new(tmp_dir, "") }
10
10
  let(:config_file_path) { File.join(tmp_dir, "config", "appsignal.yml") }
11
11
  let(:config_file) { File.read(config_file_path) }
12
+ let(:options) { {} }
12
13
  before do
13
14
  stub_api_validation_request
14
15
  # Stub calls to speed up tests
@@ -91,7 +92,7 @@ describe Appsignal::CLI::Install do
91
92
  Dir.chdir tmp_dir do
92
93
  prepare_cli_input
93
94
  capture_stdout(out_stream) do
94
- run_cli(["install", push_api_key])
95
+ run_cli(["install", push_api_key], options)
95
96
  end
96
97
  end
97
98
  end
@@ -667,6 +668,34 @@ describe Appsignal::CLI::Install do
667
668
  it_behaves_like "push_api_key validation"
668
669
  it_behaves_like "demo data"
669
670
 
671
+ context "without color options" do
672
+ let(:options) { {} }
673
+
674
+ it "prints the instructions in color" do
675
+ run
676
+ expect(output).to have_colorized_text(:green, "## Starting AppSignal Installer ##")
677
+ end
678
+ end
679
+
680
+ context "with --color option" do
681
+ let(:options) { { "color" => nil } }
682
+
683
+ it "prints the instructions in color" do
684
+ run
685
+ expect(output).to have_colorized_text(:green, "## Starting AppSignal Installer ##")
686
+ end
687
+ end
688
+
689
+ context "with --no-color option" do
690
+ let(:options) { { "no-color" => nil } }
691
+
692
+ it "prints the instructions without special colors" do
693
+ run
694
+ expect(output).to include("Starting AppSignal Installer")
695
+ expect(output).to_not have_color_markers
696
+ end
697
+ end
698
+
670
699
  it "prints a message about unknown framework" do
671
700
  run
672
701
 
@@ -47,15 +47,43 @@ describe Appsignal::Config do
47
47
  subject { config[:active] }
48
48
 
49
49
  context "with APPSIGNAL_PUSH_API_KEY env variable" do
50
- before { ENV["APPSIGNAL_PUSH_API_KEY"] = "abc" }
50
+ context "when not empty" do
51
+ before { ENV["APPSIGNAL_PUSH_API_KEY"] = "abc" }
51
52
 
52
- it "becomes active" do
53
- expect(subject).to be_truthy
53
+ it "becomes active" do
54
+ expect(subject).to be_truthy
55
+ end
56
+
57
+ it "sets the push_api_key as loaded through the env_config" do
58
+ expect(config.env_config).to eq(:push_api_key => "abc")
59
+ expect(config.system_config).to eq(:active => true)
60
+ end
61
+ end
62
+
63
+ context "when empty string" do
64
+ before { ENV["APPSIGNAL_PUSH_API_KEY"] = "" }
65
+
66
+ it "does not becomes active" do
67
+ expect(subject).to be_falsy
68
+ end
69
+
70
+ it "sets the push_api_key as loaded through the env_config" do
71
+ expect(config.env_config).to eq(:push_api_key => "")
72
+ expect(config.system_config).to be_empty
73
+ end
54
74
  end
55
75
 
56
- it "sets the push_api_key as loaded through the env_config" do
57
- expect(config.env_config).to eq(:push_api_key => "abc")
58
- expect(config.system_config).to eq(:active => true)
76
+ context "when blank string" do
77
+ before { ENV["APPSIGNAL_PUSH_API_KEY"] = " " }
78
+
79
+ it "does not becomes active" do
80
+ expect(subject).to be_falsy
81
+ end
82
+
83
+ it "sets the push_api_key as loaded through the env_config" do
84
+ expect(config.env_config).to eq(:push_api_key => " ")
85
+ expect(config.system_config).to be_empty
86
+ end
59
87
  end
60
88
  end
61
89
 
@@ -134,6 +162,7 @@ describe Appsignal::Config do
134
162
  :ca_file_path => File.join(resources_dir, "cacert.pem"),
135
163
  :dns_servers => [],
136
164
  :files_world_accessible => true,
165
+ :transaction_debug_mode => false,
137
166
  :revision => "v2.5.1",
138
167
  :request_headers => []
139
168
  )
@@ -214,6 +243,30 @@ describe Appsignal::Config do
214
243
  end
215
244
  end
216
245
 
246
+ context "with the config file causing an error" do
247
+ let(:config_path) do
248
+ File.expand_path(
249
+ File.join(File.dirname(__FILE__), "../../support/fixtures/projects/broken")
250
+ )
251
+ end
252
+ let(:config) { Appsignal::Config.new(config_path, "foo") }
253
+
254
+ it "logs & prints an error, skipping the file source" do
255
+ stdout = std_stream
256
+ stderr = std_stream
257
+ log = capture_logs { capture_std_streams(stdout, stderr) { config } }
258
+ message = "An error occured while loading the AppSignal config file. " \
259
+ "Skipping file config.\n" \
260
+ "File: #{File.join(config_path, "config", "appsignal.yml").inspect}\n" \
261
+ "NotExistingConstant: uninitialized constant NotExistingConstant\n"
262
+ expect(log).to contains_log :error, message
263
+ expect(log).to include("/appsignal/config.rb:") # Backtrace
264
+ expect(stdout.read).to_not include("appsignal:")
265
+ expect(stderr.read).to include "appsignal: #{message}"
266
+ expect(config.file_config).to eql({})
267
+ end
268
+ end
269
+
217
270
  it "sets the file_config" do
218
271
  # config found in spec/support/project_fixture/config/appsignal.yml
219
272
  expect(config.file_config).to match(
@@ -264,7 +317,7 @@ describe Appsignal::Config do
264
317
  expect_any_instance_of(Logger).to receive(:error).once
265
318
  .with("Not loading from config file: config for 'nonsense' not found")
266
319
  expect_any_instance_of(Logger).to receive(:error).once
267
- .with("Push api key not set after loading config")
320
+ .with("Push API key not set after loading config")
268
321
  config
269
322
  end
270
323
  end
@@ -473,6 +526,7 @@ describe Appsignal::Config do
473
526
  config[:filter_parameters] = %w[password confirm_password]
474
527
  config[:running_in_container] = false
475
528
  config[:dns_servers] = ["8.8.8.8", "8.8.4.4"]
529
+ config[:transaction_debug_mode] = true
476
530
  config[:revision] = "v2.5.1"
477
531
  config.write_to_environment
478
532
  end
@@ -500,6 +554,7 @@ describe Appsignal::Config do
500
554
  expect(ENV["_APPSIGNAL_CA_FILE_PATH"]).to eq File.join(resources_dir, "cacert.pem")
501
555
  expect(ENV["_APPSIGNAL_DNS_SERVERS"]).to eq "8.8.8.8,8.8.4.4"
502
556
  expect(ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"]).to eq "true"
557
+ expect(ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"]).to eq "true"
503
558
  expect(ENV["_APP_REVISION"]).to eq "v2.5.1"
504
559
  expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
505
560
  expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIRECTORY_PATH")
@@ -721,6 +776,22 @@ describe Appsignal::Config do
721
776
  end
722
777
  end
723
778
 
779
+ context "with empty push_api_key" do
780
+ let(:push_api_key) { "" }
781
+
782
+ it "sets valid to false" do
783
+ is_expected.to eq(false)
784
+ end
785
+ end
786
+
787
+ context "with blank push_api_key" do
788
+ let(:push_api_key) { " " }
789
+
790
+ it "sets valid to false" do
791
+ is_expected.to eq(false)
792
+ end
793
+ end
794
+
724
795
  context "with push_api_key present" do
725
796
  let(:push_api_key) { "abc" }
726
797
 
@@ -54,16 +54,12 @@ describe Appsignal::Hooks::ActionCableHook do
54
54
  .with(transaction_id, Appsignal::Transaction::ACTION_CABLE, kind_of(ActionDispatch::Request))
55
55
  .and_return(transaction)
56
56
  allow(Appsignal::Transaction).to receive(:current).and_return(transaction)
57
- # Make sure sample data is added
58
- expect(transaction.ext).to receive(:finish).and_return(true)
59
- # Stub complete call, stops it from being cleared in the extension
60
- # And allows us to call `#to_h` on it after it's been completed.
61
- expect(transaction.ext).to receive(:complete)
62
57
 
63
58
  # Stub transmit call for subscribe/unsubscribe tests
64
59
  allow(connection).to receive(:websocket)
65
60
  .and_return(instance_double("ActionCable::Connection::WebSocket", :transmit => nil))
66
61
  end
62
+ around { |example| keep_transactions { example.run } }
67
63
 
68
64
  describe "#perform_action" do
69
65
  it "creates a transaction for an action" do
@@ -4,69 +4,71 @@ describe Appsignal::Hooks::RakeHook do
4
4
  let(:task) { Rake::Task.new("task:name", Rake::Application.new) }
5
5
  let(:arguments) { Rake::TaskArguments.new(["foo"], ["bar"]) }
6
6
  let(:generic_request) { Appsignal::Transaction::GenericRequest.new({}) }
7
- before(:context) do
8
- Appsignal.config = project_fixture_config
9
- expect(Appsignal.active?).to be_truthy
10
- Appsignal::Hooks.load_hooks
11
- end
7
+ before(:context) { start_agent }
12
8
 
13
9
  describe "#execute" do
14
10
  context "without error" do
11
+ before { expect(Appsignal).to_not receive(:stop) }
12
+
13
+ def perform
14
+ task.execute(arguments)
15
+ end
16
+
15
17
  it "creates no transaction" do
16
- expect(Appsignal::Transaction).to_not receive(:create)
18
+ expect(Appsignal::Transaction).to_not receive(:new)
19
+ expect { perform }.to_not(change { created_transactions })
17
20
  end
18
21
 
19
22
  it "calls the original task" do
20
- expect(task).to receive(:execute_without_appsignal).with("foo")
23
+ expect(task).to receive(:execute_without_appsignal).with(arguments)
24
+ perform
21
25
  end
22
-
23
- after { task.execute("foo") }
24
26
  end
25
27
 
26
28
  context "with error" do
27
29
  let(:error) { ExampleException }
28
- let(:transaction) { background_job_transaction }
29
30
  before do
30
- task.enhance { raise error }
31
-
32
- expect(Appsignal::Transaction).to receive(:create).with(
33
- kind_of(String),
34
- Appsignal::Transaction::BACKGROUND_JOB,
35
- kind_of(Appsignal::Transaction::GenericRequest)
36
- ).and_return(transaction)
31
+ task.enhance { raise error, "my error message" }
32
+ # We don't call `and_call_original` here as we don't want AppSignal to
33
+ # stop and start for every spec.
34
+ expect(Appsignal).to receive(:stop).with("rake")
37
35
  end
38
36
 
39
- it "sets the action" do
40
- expect(transaction).to receive(:set_action).with("task:name")
41
- end
42
-
43
- it "sets the error" do
44
- expect(transaction).to receive(:set_error).with(error)
37
+ def perform
38
+ keep_transactions do
39
+ expect { task.execute(arguments) }.to raise_error(error)
40
+ end
45
41
  end
46
42
 
47
- it "completes the transaction and stops" do
48
- expect(transaction).to receive(:complete).ordered
49
- expect(Appsignal).to receive(:stop).with("rake").ordered
50
- end
43
+ it "creates a background job transaction" do
44
+ perform
51
45
 
52
- it "adds the task arguments to the request" do
53
- expect(Appsignal::Transaction::GenericRequest).to receive(:new)
54
- .with(:params => { :foo => "bar" })
55
- .and_return(generic_request)
46
+ expect(last_transaction).to be_completed
47
+ expect(last_transaction.to_h).to include(
48
+ "id" => kind_of(String),
49
+ "namespace" => Appsignal::Transaction::BACKGROUND_JOB,
50
+ "action" => "task:name",
51
+ "error" => {
52
+ "name" => "ExampleException",
53
+ "message" => "my error message",
54
+ "backtrace" => kind_of(String)
55
+ },
56
+ "sample_data" => hash_including(
57
+ "params" => { "foo" => "bar" }
58
+ )
59
+ )
56
60
  end
57
61
 
58
62
  context "when first argument is not a `Rake::TaskArguments`" do
59
63
  let(:arguments) { nil }
60
64
 
61
- it "adds the first argument regardless" do
62
- expect(Appsignal::Transaction::GenericRequest).to receive(:new)
63
- .with(:params => nil)
64
- .and_return(generic_request)
65
- end
66
- end
65
+ it "does not add the params to the transaction" do
66
+ perform
67
67
 
68
- after do
69
- expect { task.execute(arguments) }.to raise_error ExampleException
68
+ expect(last_transaction.to_h).to include(
69
+ "sample_data" => hash_excluding("params")
70
+ )
71
+ end
70
72
  end
71
73
  end
72
74
  end