Skip to content

Commit 2d2516a

Browse files
committed
Add spec for coercion of nil argument
1 parent 9714111 commit 2d2516a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/coercion_of_nil_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
describe "coercion of nil" do
2+
before do
3+
class Test::Foo
4+
extend Dry::Initializer
5+
param :bar, proc(&:to_i)
6+
end
7+
8+
class Test::Baz
9+
include Dry::Initializer.define -> do
10+
param :qux, proc(&:to_i)
11+
end
12+
end
13+
end
14+
15+
let(:foo) { Test::Foo.new(nil) }
16+
let(:baz) { Test::Baz.new(nil) }
17+
18+
it "works with extend syntax" do
19+
expect(foo.bar).to eq 0
20+
end
21+
22+
it "works with include syntax" do
23+
expect(baz.qux).to eq 0
24+
end
25+
end

0 commit comments

Comments
 (0)