Sha256: 77e1f95ff751d11d8dbe7552f5c4ef6d34f9c9b03d54cf6f883aa191cb473f74
Contents?: true
Size: 1.83 KB
Versions: 4
Compression:
Stored size: 1.83 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
4 entries across 4 versions & 1 rubygems