Sha256: f12b1b3f3c3509a6d5aa7cc523115a96989293840b73d502e1aaef80012591eb
Contents?: true
Size: 856 Bytes
Versions: 2
Compression:
Stored size: 856 Bytes
Contents
describe "@__options__" do context "when class has no options" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo end end it "is set to empty hash" do subject = Test::Foo.new(1) expect(subject.instance_variable_get(:@__options__)).to eq({}) end end context "when class has options" do before do class Test::Foo extend Dry::Initializer::Mixin option :foo option :bar, default: proc { 1 } option :baz, optional: true option :qux, proc(&:to_s), as: :quxx end end it "collects coerced and renamed options with default values" do subject = Test::Foo.new(foo: :FOO, qux: :QUX) expect(subject.instance_variable_get(:@__options__)) .to eq({ foo: :FOO, bar: 1, quxx: "QUX" }) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-1.3.0 | spec/options_var_spec.rb |
dry-initializer-1.2.0 | spec/options_var_spec.rb |