spec/lib/appsignal/hooks/rake_spec.rb in appsignal-2.3.1 vs spec/lib/appsignal/hooks/rake_spec.rb in appsignal-2.3.2

- old
+ new

@@ -1,9 +1,11 @@ require "rake" describe Appsignal::Hooks::RakeHook do let(:task) { Rake::Task.new("task:name", Rake::Application.new) } + let(:arguments) { Rake::TaskArguments.new(["foo"], ["bar"]) } + let(:generic_request) { Appsignal::Transaction::GenericRequest.new({}) } before(:context) do Appsignal.config = project_fixture_config expect(Appsignal.active?).to be_truthy Appsignal::Hooks.load_hooks end @@ -45,11 +47,27 @@ it "completes the transaction and stops" do expect(transaction).to receive(:complete).ordered expect(Appsignal).to receive(:stop).with("rake").ordered end + it "adds the task arguments to the request" do + expect(Appsignal::Transaction::GenericRequest).to receive(:new) + .with(:params => { :foo => "bar" }) + .and_return(generic_request) + end + + context "when first argument is not a `Rake::TaskArguments`" do + let(:arguments) { nil } + + it "adds the first argument regardless" do + expect(Appsignal::Transaction::GenericRequest).to receive(:new) + .with(:params => nil) + .and_return(generic_request) + end + end + after do - expect { task.execute("foo") }.to raise_error VerySpecificError + expect { task.execute(arguments) }.to raise_error VerySpecificError end end end end