Sha256: eb63da5b16d0167f62e7f93040b70bd4e64c2d3a16fb27f7aec02e0022c03225
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
require "spec_helper" describe AttrExtras::AttrInitialize::ParamsBuilder do subject { AttrExtras::AttrInitialize::ParamsBuilder.new(names) } describe "when positional and hash params are present" do let(:names) { [ :foo, :bar, [ :baz, :qux!, quux: "Quux" ]] } it "properly devides params by the type" do subject.positional_args.must_equal [ :foo, :bar ] subject.hash_args.must_equal [ :baz, :qux!, :quux ] subject.hash_args_names.must_equal [ :baz, :qux, :quux ] subject.hash_args_required.must_equal [ :qux ] subject.default_values.must_equal({ quux: "Quux" }) end end describe "when only positional params are present" do let(:names) { [ :foo, :bar] } it "properly devides params by the type" do subject.positional_args.must_equal [ :foo, :bar ] subject.hash_args.must_be_empty subject.hash_args_names.must_be_empty subject.hash_args_required.must_be_empty subject.default_values.must_be_empty end end describe "when only hash params are present" do let(:names) { [[ { baz: "Baz" }, :qux!, { quux: "Quux" } ]] } it "properly devides params by the type" do subject.positional_args.must_be_empty subject.hash_args.must_equal [ :baz, :qux!, :quux ] subject.hash_args_names.must_equal [ :baz, :qux, :quux ] subject.hash_args_required.must_equal [ :qux ] subject.default_values.must_equal({ quux: "Quux", baz: "Baz" }) end end describe "when params are empty" do let(:names) { [] } it "properly devides params by the type" do subject.positional_args.must_be_empty subject.hash_args.must_be_empty subject.hash_args_names.must_be_empty subject.hash_args_required.must_be_empty subject.default_values.must_be_empty end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
attr_extras-6.2.1 | spec/attr_extras/params_builder_spec.rb |
attr_extras-6.2.0 | spec/attr_extras/params_builder_spec.rb |
attr_extras-6.1.0 | spec/attr_extras/params_builder_spec.rb |