Skip to content

Commit

Permalink
Add spec for coercion of nil argument
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Aug 7, 2018
1 parent 9714111 commit 2d2516a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/coercion_of_nil_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe "coercion of nil" do
before do
class Test::Foo
extend Dry::Initializer
param :bar, proc(&:to_i)
end

class Test::Baz
include Dry::Initializer.define -> do
param :qux, proc(&:to_i)
end
end
end

let(:foo) { Test::Foo.new(nil) }
let(:baz) { Test::Baz.new(nil) }

it "works with extend syntax" do
expect(foo.bar).to eq 0
end

it "works with include syntax" do
expect(baz.qux).to eq 0
end
end

0 comments on commit 2d2516a

Please sign in to comment.