Sha256: 370f0b43dd8e34c5c64bb3d03af5c8a190f63179fd7517a505798ee99cc4a298

Contents?: true

Size: 803 Bytes

Versions: 24

Compression:

Stored size: 803 Bytes

Contents

RSpec.describe "EitilCore 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

24 entries across 24 versions & 1 rubygems

Version Path
eitil-2.0.8 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.7 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.6 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.5 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.4 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.3 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.2 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.1 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-2.0.0 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.4.1 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.4.0 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.12 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.11 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.10 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.9 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.8 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.7 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.6 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.5 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb
eitil-1.3.4 spec/eitil_core/argument_helpers/all_kwargs_to_ivars_bang_spec.rb