-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhooks_spec.rb
More file actions
59 lines (46 loc) · 2.06 KB
/
hooks_spec.rb
File metadata and controls
59 lines (46 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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