Skip to content

Commit

Permalink
Implement config serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Sep 28, 2023
1 parent 22a759c commit bdb82ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/kangaru/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def initialize
@configurators = set_configurators!
end

def serialise
configurators.transform_values(&:serialise)
end

private

def set_configurators!
Expand Down
2 changes: 2 additions & 0 deletions sig/kangaru/config.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Kangaru

def initialize: -> void

def serialise: -> Hash[Symbol, Hash[Symbol, untyped]]

private

def set_configurators!: -> Hash[Symbol, configurator]
Expand Down
20 changes: 20 additions & 0 deletions spec/kangaru/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,24 @@
end
end
end

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

context "when no configurators defined" do
include_context :no_configurators_defined

it "returns an empty hash" do
expect(hash).to be_empty
end
end

context "when configurators set" do
include_context :configurator_defined

it "returns the expected hash" do
expect(hash).to eq(foobar: { hello: "world" })
end
end
end
end

0 comments on commit bdb82ed

Please sign in to comment.