Skip to content

Commit

Permalink
Implement application config
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Sep 28, 2023
1 parent bdb82ed commit 6f24567
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/kangaru/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def initialize(name:, dir:, namespace:)
@namespace = namespace
end

def config
@config ||= Config.new
end

def setup
autoloader.setup
end
Expand Down
4 changes: 4 additions & 0 deletions sig/kangaru/application.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ module Kangaru
attr_reader dir: String
attr_reader namespace: Module

@config: Config

def initialize: (name: String, dir: String, namespace: Module) -> void

def config: -> Config

def setup: -> void

def run!: (Array[String]) -> void
Expand Down
15 changes: 15 additions & 0 deletions spec/kangaru/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

before { stub_const "SomeApp", Module.new }

describe "#config" do
subject(:config) { application.config }

it "returns a config object" do
expect(config).to be_a(Kangaru::Config)
end

it "caches the config object" do
expect { config }
.to change { application.instance_variable_defined?(:@config) }
.from(false)
.to(true)
end
end

describe "#setup" do
subject(:setup) { application.setup }

Expand Down

0 comments on commit 6f24567

Please sign in to comment.