diff --git a/lib/kangaru/initialiser.rb b/lib/kangaru/initialiser.rb index f15a12d..088765b 100644 --- a/lib/kangaru/initialiser.rb +++ b/lib/kangaru/initialiser.rb @@ -4,6 +4,12 @@ def self.extended(namespace) root_file = caller[0].gsub(/:.*$/, "") Kangaru.application = Application.new(root_file:, namespace:).tap(&:setup) + + namespace.module_eval do + def self.run!(argv) + Kangaru.application.run!(argv) + end + end end end end diff --git a/spec/features/initialiser_spec.rb b/spec/features/initialiser_spec.rb index 352641b..8bf9c24 100644 --- a/spec/features/initialiser_spec.rb +++ b/spec/features/initialiser_spec.rb @@ -36,6 +36,11 @@ module SomeGem it "does not set the Kangaru application reference" do expect { require_gem }.not_to change { Kangaru.application }.from(nil) end + + it "does not define the run! method in the gem's root module" do + require_gem + expect(SomeGem).not_to respond_to(:run!) + end end context "when the target gem extends the initialiser" do @@ -70,6 +75,11 @@ module SomeGem .to(a_kind_of(Kangaru::Application)) end + it "defines the run! method in the gem's root module" do + require_gem + expect(SomeGem).to respond_to(:run!) + end + describe "application reference" do subject(:application) { Kangaru.application }