-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp the minitesting bundled configuration so it uses Rack::Test an…
…d the Roda server
- Loading branch information
1 parent
7f48f7e
commit 533cc77
Showing
5 changed files
with
93 additions
and
92 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
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
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,47 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file can be required by project test suites to set up the Minitest environment | ||
|
||
require "bridgetown" | ||
|
||
ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] = nil | ||
Bridgetown.begin! | ||
|
||
Bridgetown::Builders::PluginBuilder.then do | ||
Bridgetown::Builders::DSL::Inspectors.setup_nokolexbor | ||
end | ||
|
||
require "bridgetown-core/rack/boot" | ||
class Bridgetown::Rack::Logger | ||
def add(*) | ||
super if ENV["SERVER_LOGS"] == "true" | ||
end | ||
end | ||
|
||
Bridgetown::Current.preloaded_configuration = Bridgetown.configuration | ||
Bridgetown::Rack.boot | ||
|
||
require "rack/test" | ||
|
||
class Bridgetown::Test < Minitest::Test | ||
include Rack::Test::Methods | ||
|
||
attr_reader :document | ||
|
||
def roda_app_class = RodaApp | ||
|
||
def app = roda_app_class.app | ||
|
||
def site | ||
roda_app_class.opts[:bridgetown_site] | ||
end | ||
|
||
def html(request) = @document = Nokolexbor::Document.parse(request.body) | ||
|
||
def json(request) = @document = JSON.parse(request.body) | ||
|
||
def routes = JSON.parse(File.read( | ||
File.join(Bridgetown::Current.preloaded_configuration.root_dir, | ||
".routes.json") | ||
)) | ||
end |