Sha256: 84b3756e0e105e2b8f1ba16e4b8e8807ec1cdd5c4bc3fb96d4258b22766b7493
Contents?: true
Size: 938 Bytes
Versions: 9
Compression:
Stored size: 938 Bytes
Contents
describe "attribute with several assignments" do before do class Test::Foo extend Dry::Initializer option :bar, proc(&:to_s), optional: true option :"some foo", as: :bar, optional: true end end context "when not defined" do subject { Test::Foo.new } it "is left undefined" do expect(subject.bar).to be_nil expect(subject.instance_variable_get :@bar) .to eq Dry::Initializer::UNDEFINED end end context "when set directly" do subject { Test::Foo.new bar: :BAZ } it "sets the attribute" do expect(subject.bar).to eq "BAZ" end end context "when renamed" do subject { Test::Foo.new "some foo": :BAZ } it "renames the attribute" do expect(subject.bar).to eq :BAZ expect(subject).not_to respond_to :foo end it "renames the variable" do expect(subject.instance_variable_get(:@bar)).to eq :BAZ end end end
Version data entries
9 entries across 9 versions & 1 rubygems