Skip to content

Commit

Permalink
Add specs for Container#merge with a block
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Jul 10, 2022
1 parent 5afce79 commit eb5096f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/support/shared_examples/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,32 @@
it { expect(container["#{namespace}.#{key}"]).to be(:item) }
end
end

context "with a block resolving conflicts" do
before do
container.register(:conflicting_key, "original")
other.register(:conflicting_key, "from other")
end

it "resolves conflict using provided block" do
container.merge(other) { |_, left, right| left }

expect(container[:conflicting_key]).to eql("original")
end
end

context "with a block resolving conflicts with a namespace" do
before do
container.register("items.conflicting_key", "original")
other.register("conflicting_key", "from other")
end

it "resolves conflict using provided block" do
container.merge(other, namespace: "items") { |_, left, right| left }

expect(container["items.conflicting_key"]).to eql("original")
end
end
end

describe "#key?" do
Expand Down

0 comments on commit eb5096f

Please sign in to comment.