Sha256: 2ed5edff210f1d1a1e20ce2542338854aa20a98d89de1b5e39cb4447baf0a213
Contents?: true
Size: 808 Bytes
Versions: 4
Compression:
Stored size: 808 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 binding, :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 binding, :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