Sha256: 18dc04288399c36c3d984321d903272de5004af5774efad8da33a60c74d00e74

Contents?: true

Size: 905 Bytes

Versions: 24

Compression:

Stored size: 905 Bytes

Contents

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

24 entries across 24 versions & 1 rubygems

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