Skip to content

Commit

Permalink
Update Initialiser to autoload Initialisers module
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Oct 26, 2023
1 parent 444ec16 commit af13c38
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/kangaru/initialiser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def self.extended(namespace)
source = caller[0].gsub(/:.*$/, "")

Kangaru.application = Application.new(source:, namespace:)
Kangaru.eager_load(Initialisers)

namespace.extend InjectedMethods
end
Expand Down
4 changes: 4 additions & 0 deletions lib/kangaru/initialisers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Kangaru
module Initialisers
end
end
4 changes: 4 additions & 0 deletions sig/kangaru/initialisers.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Kangaru
module Initialisers
end
end
10 changes: 10 additions & 0 deletions spec/kangaru/initialiser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
stub_const "Namespace", Module.new

allow(Kangaru::Application).to receive(:new).and_return(application)
allow(Kangaru).to receive(:eager_load)

allow_any_instance_of(Kernel).to receive(:caller).and_return([callsite])
end
Expand Down Expand Up @@ -40,6 +41,15 @@
.to change { Kangaru.application }
.to(application)
end

it "eager loads the Initialisers namespace" do
extended

expect(Kangaru)
.to have_received(:eager_load)
.with(Kangaru::Initialisers)
.once
end
end

context "when calling file is not in a gem structure" do
Expand Down

0 comments on commit af13c38

Please sign in to comment.