Sha256: 32c16480f4233c3c2bb4af29842ed01576f657277f2767bfc5785d89381954f3

Contents?: true

Size: 872 Bytes

Versions: 4

Compression:

Stored size: 872 Bytes

Contents

RSpec.describe "Kernel#args_to_ivars!" do

  it "should set the given positional arguments to instance variables" do

    def test_method(a, b, c)
      args_to_ivars! :a, :c
    end

    test_method(1, "two", :three)

    expect(@a).to eq 1
    expect(@b).to be_nil
    expect(@c).to eq :three
    expect(@d).to be_nil

  end

  it "should set the given keyword arguments to instance variables" do

    def test_method(a:, b:, c:)
      args_to_ivars! :a, :c
    end

    test_method(a: 1, b: "two", c: :three)

    expect(@a).to eq 1
    expect(@b).to be_nil
    expect(@c).to eq :three
    expect(@d).to be_nil

  end

  it "should set the given local variables to instance variables" do

    a = 1
    b = "two"
    c = :three

    args_to_ivars! :a, :c

    expect(@a).to eq 1
    expect(@b).to be_nil
    expect(@c).to eq :three
    expect(@d).to be_nil

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eitil-1.2.4 spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb
eitil-1.2.3 spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb
eitil-1.2.2 spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb
eitil-1.2.1 spec/eitil_core/argument_helpers/args_to_ivars_bang_spec.rb