|
32 | 32 | end
|
33 | 33 |
|
34 | 34 | describe ".create_example_error_request" do
|
35 |
| - let!(:error_transaction) { http_request_transaction } |
36 |
| - let(:config) { project_fixture_config("production") } |
37 |
| - before do |
38 |
| - Appsignal.config = config |
39 |
| - expect(Appsignal::Transaction).to receive(:new).with( |
40 |
| - kind_of(String), |
41 |
| - Appsignal::Transaction::HTTP_REQUEST, |
42 |
| - kind_of(::Rack::Request), |
43 |
| - kind_of(Hash) |
44 |
| - ).and_return(error_transaction) |
45 |
| - end |
46 |
| - subject { described_class.send(:create_example_error_request) } |
| 35 | + before { start_agent } |
| 36 | + around { |example| keep_transactions { example.run } } |
47 | 37 |
|
48 | 38 | it "sets an error" do
|
49 |
| - expect(error_transaction).to receive(:set_error).with(kind_of(described_class::TestError)) |
50 |
| - expect(error_transaction).to receive(:set_metadata).with("path", "/hello") |
51 |
| - expect(error_transaction).to receive(:set_metadata).with("method", "GET") |
52 |
| - expect(error_transaction).to receive(:set_metadata).with("demo_sample", "true") |
53 |
| - expect(error_transaction).to receive(:complete) |
54 |
| - subject |
| 39 | + described_class.send(:create_example_error_request) |
| 40 | + |
| 41 | + transaction = last_transaction |
| 42 | + expect(transaction).to have_id |
| 43 | + expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST) |
| 44 | + expect(transaction).to have_action("DemoController#hello") |
| 45 | + expect(transaction).to have_error( |
| 46 | + "Appsignal::Demo::TestError", |
| 47 | + "Hello world! This is an error used for demonstration purposes." |
| 48 | + ) |
| 49 | + expect(transaction).to include_metadata( |
| 50 | + "path" => "/hello", |
| 51 | + "method" => "GET", |
| 52 | + "demo_sample" => "true" |
| 53 | + ) |
| 54 | + expect(transaction).to be_completed |
55 | 55 | end
|
56 | 56 | end
|
57 | 57 |
|
58 | 58 | describe ".create_example_performance_request" do
|
59 |
| - let!(:performance_transaction) { http_request_transaction } |
60 |
| - let(:config) { project_fixture_config("production") } |
61 |
| - before do |
62 |
| - Appsignal.config = config |
63 |
| - expect(Appsignal::Transaction).to receive(:new).with( |
64 |
| - kind_of(String), |
65 |
| - Appsignal::Transaction::HTTP_REQUEST, |
66 |
| - kind_of(::Rack::Request), |
67 |
| - kind_of(Hash) |
68 |
| - ).and_return(performance_transaction) |
69 |
| - end |
70 |
| - subject { described_class.send(:create_example_performance_request) } |
| 59 | + before { start_agent } |
| 60 | + around { |example| keep_transactions { example.run } } |
71 | 61 |
|
72 | 62 | it "sends a performance sample" do
|
73 |
| - expect(performance_transaction).to receive(:start_event) |
74 |
| - expect(performance_transaction).to receive(:finish_event).with( |
75 |
| - "action_view.render", |
76 |
| - "Render hello.html.erb", |
77 |
| - "<h1>Hello world!</h1>", |
78 |
| - Appsignal::EventFormatter::DEFAULT |
| 63 | + described_class.send(:create_example_performance_request) |
| 64 | + |
| 65 | + transaction = last_transaction |
| 66 | + expect(transaction).to have_id |
| 67 | + expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST) |
| 68 | + expect(transaction).to have_action("DemoController#hello") |
| 69 | + expect(transaction).to_not have_error |
| 70 | + expect(transaction).to include_metadata( |
| 71 | + "path" => "/hello", |
| 72 | + "method" => "GET", |
| 73 | + "demo_sample" => "true" |
| 74 | + ) |
| 75 | + expect(transaction).to include_event( |
| 76 | + "name" => "action_view.render", |
| 77 | + "title" => "Render hello.html.erb", |
| 78 | + "body" => "<h1>Hello world!</h1>", |
| 79 | + "body_format" => Appsignal::EventFormatter::DEFAULT |
79 | 80 | )
|
80 |
| - expect(performance_transaction).to receive(:set_metadata).with("path", "/hello") |
81 |
| - expect(performance_transaction).to receive(:set_metadata).with("method", "GET") |
82 |
| - expect(performance_transaction).to receive(:set_metadata).with("demo_sample", "true") |
83 |
| - expect(performance_transaction).to receive(:complete) |
84 |
| - subject |
| 81 | + expect(transaction).to be_completed |
85 | 82 | end
|
86 | 83 | end
|
87 | 84 | end
|
0 commit comments