Sha256: b6d07328c99b31c32f41aa613f4d2fd75ffab4fa2ba9f39dc66c18b7483c4db8
Contents?: true
Size: 793 Bytes
Versions: 4
Compression:
Stored size: 793 Bytes
Contents
RSpec.describe "Kernel#all_kwargs_to_ivars!" do it "should set all hash keys, nested within a positional hash, to instance variables" do def test_method(a, b, c, kwargs) all_kwargs_to_ivars! :kwargs end test_method(1, "two", :three, {a: 0, b: "not_two", c: :not_three}) expect(@a).to eq 0 expect(@b).to eq "not_two" expect(@c).to eq :not_three expect(@d).to be_nil end it "should set all hash keys, nested within a keyword hash, to instance variables" do def test_method(a, b, c, kwargs:) all_kwargs_to_ivars! :kwargs end test_method(1, "two", :three, kwargs: {a: 0, b: "not_two", c: :not_three}) expect(@a).to eq 0 expect(@b).to eq "not_two" expect(@c).to eq :not_three expect(@d).to be_nil end end
Version data entries
4 entries across 4 versions & 1 rubygems