Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ BUNDLE_CACHE_PATH: "vendor/cache"
BUNDLE_CACHE_ALL: "true"
BUNDLE_SPECIFIC_PLATFORM: "true"
BUNDLE_NO_INSTALL: "true"
BUNDLE_DEPLOYMENT: "true"
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The linter is powered by `rubocop` with its config file located at `.rubocop.yml
- Naming of variables and methods that lead to expressions and blocks reading more like English sentences.
- Less lines of code over more. Keep changes minimal and focused.
- The `docs/design.md` file is the main design document for the project. It might be out-of-date but it should still contain a general high-level overview of the project.
- Do not modify the `.bundle/config` file.

## Pull Request Requirements

Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ GitHub/InsecureHashAlgorithm:
Exclude:
- "spec/unit/lib/hooks/plugins/request_validator/hmac_spec.rb"

GitHub/AvoidObjectSendWithDynamicMethod:
Exclude:
- "spec/unit/lib/hooks/core/logger_factory_spec.rb"

Style/HashSyntax:
Enabled: false
2 changes: 2 additions & 0 deletions lib/hooks/core/signal_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def request_shutdown

# Setup signal traps for graceful shutdown
# NOTE: Disabled for now to let Puma handle signals properly
# :nocov:
def setup_signal_traps
%w[SIGINT SIGTERM].each do |signal|
Signal.trap(signal) do
Expand All @@ -48,6 +49,7 @@ def setup_signal_traps
end
end
end
# :nocov:
end
end
end
56 changes: 56 additions & 0 deletions spec/unit/hooks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
# frozen_string_literal: true

require_relative "spec_helper"

describe Hooks do
describe ".build" do
context "with default parameters" do
it "creates a builder and builds the application" do
allow(Hooks::Core::Builder).to receive(:new).and_call_original
allow_any_instance_of(Hooks::Core::Builder).to receive(:build).and_return("mock_app")
Copy link

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Avoid allow_any_instance_of as it's considered a test smell; prefer injecting a test double or explicit instance stubbing to improve clarity and isolation.

Suggested change
allow_any_instance_of(Hooks::Core::Builder).to receive(:build).and_return("mock_app")
builder_instance = instance_double(Hooks::Core::Builder, build: "mock_app")
allow(Hooks::Core::Builder).to receive(:new).and_return(builder_instance)

Copilot uses AI. Check for mistakes.

result = Hooks.build

expect(Hooks::Core::Builder).to have_received(:new).with(config: nil, log: nil)
expect(result).to eq("mock_app")
end
end

context "with custom config" do
it "passes config to builder" do
config_hash = { log_level: "debug" }
allow(Hooks::Core::Builder).to receive(:new).and_call_original
allow_any_instance_of(Hooks::Core::Builder).to receive(:build).and_return("mock_app")

result = Hooks.build(config: config_hash)

expect(Hooks::Core::Builder).to have_received(:new).with(config: config_hash, log: nil)
expect(result).to eq("mock_app")
end
end

context "with custom logger" do
it "passes logger to builder" do
custom_logger = double("Logger")
allow(Hooks::Core::Builder).to receive(:new).and_call_original
allow_any_instance_of(Hooks::Core::Builder).to receive(:build).and_return("mock_app")

result = Hooks.build(log: custom_logger)

expect(Hooks::Core::Builder).to have_received(:new).with(config: nil, log: custom_logger)
expect(result).to eq("mock_app")
end
end

context "with both config and logger" do
it "passes both to builder" do
config_hash = { environment: "test" }
custom_logger = double("Logger")
allow(Hooks::Core::Builder).to receive(:new).and_call_original
allow_any_instance_of(Hooks::Core::Builder).to receive(:build).and_return("mock_app")

result = Hooks.build(config: config_hash, log: custom_logger)

expect(Hooks::Core::Builder).to have_received(:new).with(config: config_hash, log: custom_logger)
expect(result).to eq("mock_app")
end
end
end
end
Loading