-
Notifications
You must be signed in to change notification settings - Fork 2
Improve unit test coverage from 47.5% to 70.68% with comprehensive core component testing #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
59df74e
Initial plan for issue
Copilot 4d9674c
Initial assessment and planning for unit test coverage improvement
Copilot 87f80bf
Add comprehensive unit tests for main Hooks module and Core::ConfigLo…
Copilot 239932a
Add comprehensive unit tests for Core::ConfigValidator with 42 test c…
Copilot a7e400e
Add comprehensive unit tests for Core::LoggerFactory and Core::Signal…
Copilot d37b550
Add comprehensive unit tests for Core::Builder with 25 test cases
Copilot a84fa5f
Add comprehensive unit tests for Handlers::Base, RequestValidator::Ba…
Copilot ed0f18d
remove insane vendoring from copilot
GrantBirki 8ade6fe
revert
GrantBirki ba8d1f3
notes
GrantBirki 4633f4e
lint
GrantBirki a8a1960
cleanup
GrantBirki 9d13b50
cleanup log output
GrantBirki 41d0dd8
nocov for signal traps
GrantBirki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -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") | ||
|
|
||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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_ofas it's considered a test smell; prefer injecting a test double or explicit instance stubbing to improve clarity and isolation.