Sha256: fe70e56b2843962616157a7c27caf17da898ebd6f8977fadf1713fff4180b726
Contents?: true
Size: 1.46 KB
Versions: 9
Compression:
Stored size: 1.46 KB
Contents
describe "repetitive definitions" do subject { Test::Foo.new } context "of params" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo, default: proc { 0 } param :bar, default: proc { 1 } param :foo, default: proc { 2 } end end it "reloads the attribute" do expect(subject.foo).to eq 2 end end context "of options" do before do class Test::Foo extend Dry::Initializer::Mixin option :foo, default: proc { 0 } option :bar, default: proc { 1 } option :foo, default: proc { 2 } end end it "reloads the attribute" do expect(subject.foo).to eq 2 end end context "of param and option" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo, default: proc { 0 } option :bar, default: proc { 1 } option :foo, default: proc { 2 } end end it "reloads the attribute" do expect(subject.foo).to eq 2 end end context "of optional param and option" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo, optional: true option :bar, optional: true option :foo, optional: true end end it "allows various assignments" do expect(Test::Foo.new(1).foo).to eq 1 expect(Test::Foo.new(foo: 2).foo).to eq 2 expect(Test::Foo.new(1, foo: 2).foo).to eq 2 end end end
Version data entries
9 entries across 9 versions & 1 rubygems