Skip to content

Commit 1e564ee

Browse files
committed
test: Fix Sinatra Tests
Sinatra 4.1 now includes a stricter host authorization check by default, which caused our tests to fail. The host authorization is not enforced in development and test mode so this PR sets the Sinatra environment to run in `test` mode. See: sinatra/sinatra#2053 fixes #1252
1 parent 1147bbc commit 1e564ee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CustomError < StandardError; end
1717

1818
let(:app_one) do
1919
Class.new(Sinatra::Application) do
20+
set :raise_errors, false
2021
get '/endpoint' do
2122
'1'
2223
end
@@ -41,6 +42,7 @@ class CustomError < StandardError; end
4142

4243
let(:app_two) do
4344
Class.new(Sinatra::Application) do
45+
set :raise_errors, false
4446
get '/endpoint' do
4547
'2'
4648
end
@@ -165,7 +167,8 @@ class CustomError < StandardError; end
165167
'http.method' => 'GET',
166168
'http.route' => '/error',
167169
'http.scheme' => 'http',
168-
'http.target' => '/error'
170+
'http.target' => '/error',
171+
'http.status_code' => 500
169172
)
170173
_(exporter.finished_spans.flat_map(&:events).map(&:name)).must_equal(['exception'])
171174
end

instrumentation/sinatra/test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Copyright The OpenTelemetry Authors
44
#
55
# SPDX-License-Identifier: Apache-2.0
6+
ENV['APP_ENV'] = 'test'
67

78
require 'bundler/setup'
89
Bundler.require(:default, :development, :test)

0 commit comments

Comments
 (0)