forked from sinatra/sinatra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test file for zeitwerk functionality
Unfortunately this behaviour is only reproducible in classic sinatra app and this is the only way I can think of making it work. The problem is that this breaks another scenario in settings_test where we're expecting that Sinatra::Application.app_file is nil.
- Loading branch information
1 parent
52e935a
commit 9abff65
Showing
2 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require File.expand_path('helper', __dir__) | ||
# This needs to come first so that sinatra require goes through zeitwerk loader | ||
require 'zeitwerk' | ||
require 'sinatra' | ||
|
||
# We have to use a global variable here in order for the spec to be able to access it. | ||
# A constant would work too, but undefining that is a bit more involved. | ||
$zeitwerk_test_app_file = settings.app_file | ||
|
||
class ZeitwerkAppFileTest < Minitest::Test | ||
it 'sets app_file to the first caller ignoring Zeitwerk' do | ||
assert_equal __FILE__, $zeitwerk_test_app_file | ||
end | ||
end |