Sha256: 42e3111a82f6c5e6b630d6949c6390510d9b8949559dfc941f6ffe6d8f978d02

Contents?: true

Size: 483 Bytes

Versions: 7

Compression:

Stored size: 483 Bytes

Contents

require "test_helper"

class ExperimentalKeyErrorNameCorrectionTest < Minitest::Test
  def test_corrects_hash_key_name
    hash = { "foo" => 1, bar: 2 }

    error = assert_raises(KeyError) { hash.fetch(:bax) }
    assert_correction ":bar", error.corrections
    assert_match "Did you mean?  :bar", error.to_s

    error = assert_raises(KeyError) { hash.fetch("fooo") }
    assert_correction %("foo"), error.corrections
    assert_match %(Did you mean?  "foo"), error.to_s
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
did_you_mean-1.1.3 test/experimental/key_error_test.rb
did_you_mean-1.0.4 test/experimental/key_error_test.rb
did_you_mean-1.0.3 test/experimental/key_error_test.rb
did_you_mean-1.1.2 test/experimental/key_error_test.rb
ruby-compiler-0.1.1 vendor/ruby/gems/did_you_mean-1.1.0/test/experimental/key_error_test.rb
did_you_mean-1.1.0 test/experimental/key_error_test.rb
did_you_mean-1.0.2 test/experimental/key_error_test.rb