Sha256: c438ce09613f97035e4213c6d8fe96507b15f41c90499d98922611720f001a5b
Contents?: true
Size: 715 Bytes
Versions: 2
Compression:
Stored size: 715 Bytes
Contents
require "spec_helper" describe Object, ".rattr_initialize" do it "creates both initializer and public readers" do klass = Class.new do rattr_initialize :foo, :bar end example = klass.new("Foo", "Bar") example.public_send(:foo).must_equal "Foo" end it "works with hash ivars" do klass = Class.new do rattr_initialize :foo, [:bar, :baz!] end example = klass.new("Foo", bar: "Bar", baz: "Baz") example.public_send(:baz).must_equal "Baz" end it "accepts the alias attr_reader_initialize" do klass = Class.new do attr_reader_initialize :foo, :bar end example = klass.new("Foo", "Bar") example.public_send(:foo).must_equal "Foo" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
attr_extras-6.2.0 | spec/attr_extras/rattr_initialize_spec.rb |
attr_extras-6.1.0 | spec/attr_extras/rattr_initialize_spec.rb |