Sha256: 40f6d25d49d09e1ef0bdaa5e52daf0d6a8fae99f879e427454daa0473f10c340

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

class RequiredArgsTest < Minitest::Test
  def test_required_argument
    actual = Invokr.invoke(
      method: :required_argument,
      on:     TestMethodBank,
      with:   { album: 'junta' },
    )

    assert_equal 'junta', actual
  end

  def test_failing_to_supply_required_arguments
    error = assert_raises Invokr::MissingArgumentsError do
      Invokr.invoke(
        method: :multiple_required_arguments,
        on:     TestMethodBank,
        with:   {},
      )
    end

    assert_equal(
      "missing required argument(s) `album', `guitarist' when invoking method `multiple_required_arguments' on #<TestMethodBank:0xdeadbeef>",
      error.message,
    )
  end

  def test_refuses_to_invoke_if_unused_args_are_passed
    error = assert_raises Invokr::ExtraArgumentsError do
      Invokr.invoke(
        method: :required_argument,
        on:     TestMethodBank,
        with:   { album: 'junta', guitarist: 'trey' },
      )
    end

    assert_equal(
      "unused argument(s) `guitarist' when invoking method `required_argument' on #<TestMethodBank:0xdeadbeef>",
      error.message,
    )
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
invokr-0.9.7 test/required_args_test.rb
invokr-0.9.6 test/required_args_test.rb
invokr-0.9.5 test/required_args_test.rb
invokr-0.9.4 test/required_args_test.rb
invokr-0.9.3 test/required_args_test.rb
invokr-0.9.2 test/required_args_test.rb
invokr-0.9.1 test/required_args_test.rb
invokr-0.9.0 test/required_args_test.rb
invokr-0.1.0 test/required_args_test.rb
invokr-0.0.6 test/required_args_test.rb
invokr-0.0.5 test/required_args_test.rb
invokr-0.0.4 test/required_args_test.rb
invokr-0.0.2 test/required_args_test.rb
invokr-0.0.1 test/required_args_test.rb