Sha256: 66e58a2dd081e4d55859b482262425efd6bce7dda22bf6f165d98a3641d69fa7
Contents?: true
Size: 943 Bytes
Versions: 3
Compression:
Stored size: 943 Bytes
Contents
describe "default values" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo, default: proc { :FOO } param :bar, default: proc { :BAR } option :baz, default: proc { :BAZ } option :qux, default: proc { foo } end end it "instantiate arguments" do subject = Test::Foo.new(1, 2, baz: 3, qux: 4) expect(subject.foo).to eql 1 expect(subject.bar).to eql 2 expect(subject.baz).to eql 3 expect(subject.qux).to eql 4 end it "applies default values" do subject = Test::Foo.new expect(subject.foo).to eql :FOO expect(subject.bar).to eql :BAR expect(subject.baz).to eql :BAZ expect(subject.qux).to eql :FOO end it "applies default values partially" do subject = Test::Foo.new 1, baz: 3 expect(subject.foo).to eql 1 expect(subject.bar).to eql :BAR expect(subject.baz).to eql 3 expect(subject.qux).to eql 1 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.2.0 | spec/dry/default_values_spec.rb |
dry-initializer-0.1.1 | spec/dry/default_values_spec.rb |
dry-initializer-0.1.0 | spec/dry/default_values_spec.rb |