diff --git a/lib/kangaru/initialiser.rb b/lib/kangaru/initialiser.rb index a1e7072..55aae43 100644 --- a/lib/kangaru/initialiser.rb +++ b/lib/kangaru/initialiser.rb @@ -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 diff --git a/lib/kangaru/initialisers.rb b/lib/kangaru/initialisers.rb new file mode 100644 index 0000000..76e016e --- /dev/null +++ b/lib/kangaru/initialisers.rb @@ -0,0 +1,4 @@ +module Kangaru + module Initialisers + end +end diff --git a/sig/kangaru/initialisers.rbs b/sig/kangaru/initialisers.rbs new file mode 100644 index 0000000..76e016e --- /dev/null +++ b/sig/kangaru/initialisers.rbs @@ -0,0 +1,4 @@ +module Kangaru + module Initialisers + end +end diff --git a/spec/kangaru/initialiser_spec.rb b/spec/kangaru/initialiser_spec.rb index db589a5..a7e0dd1 100644 --- a/spec/kangaru/initialiser_spec.rb +++ b/spec/kangaru/initialiser_spec.rb @@ -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 @@ -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