-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate initializer on installation task
- Loading branch information
Showing
6 changed files
with
89 additions
and
11 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
11 changes: 11 additions & 0 deletions
11
lib/generators/disqualified/install/templates/initializer.rb
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,11 @@ | ||
Disqualified.configure_server do |config| | ||
config.delay_high = 5.0 | ||
config.delay_low = 1.0 | ||
config.logger = Rails.logger | ||
config.pool_size = 5 | ||
config.on_error do |exception, context| | ||
puts "Unhandled Disqualified error" | ||
pp exception | ||
pp context | ||
end | ||
end |
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,27 @@ | ||
# typed: strict | ||
|
||
require "test_helper" | ||
|
||
class Disqualified::ConfigurationTest < ActiveSupport::TestCase | ||
test "initializer is fine" do | ||
original_options = Disqualified.server_options | ||
|
||
Disqualified.server_options = Disqualified::ServerConfiguration.new | ||
load(File.expand_path("../../lib/generators/disqualified/install/templates/initializer.rb", __dir__)) | ||
|
||
default_server_options = Disqualified::ServerConfiguration.new | ||
initializer_options = T.must(Disqualified.server_options) | ||
|
||
assert_equal(default_server_options.delay_high, initializer_options.delay_high) | ||
assert_equal(default_server_options.delay_low, initializer_options.delay_low) | ||
assert_equal(default_server_options.logger, initializer_options.logger) | ||
assert_equal(default_server_options.pool_size, initializer_options.pool_size) | ||
assert_equal(default_server_options.pwd, initializer_options.pwd) | ||
assert_equal(1, initializer_options.error_hooks.size) | ||
assert_output(/StandardError.*orange.*mocha/m) do | ||
T.must(initializer_options.error_hooks.first).call(StandardError.new, {orange: :mocha}) | ||
end | ||
ensure | ||
Disqualified.server_options = original_options | ||
end | ||
end |
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