Sha256: 6239b404766f8d675482711f09a6cc38f214518933445afa2843f43a0b242de0

Contents?: true

Size: 592 Bytes

Versions: 3

Compression:

Stored size: 592 Bytes

Contents

require_relative '../helper'

return if !defined?(::NoMatchingPatternKeyError)

class PatternKeyNameCheckTest < Test::Unit::TestCase
  include DidYouMean::TestHelper

  def test_corrects_hash_key_name_with_single_pattern_match
    error = assert_raise(NoMatchingPatternKeyError) do
      eval(<<~RUBY, binding, __FILE__, __LINE__)
        hash = {foo: 1, bar: 2, baz: 3}
        hash => {fooo:}
        fooo = 1 # suppress "unused variable: fooo" warning
      RUBY
    end

    assert_correction ":foo", error.corrections
    assert_match "Did you mean?  :foo", get_message(error)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
did_you_mean-2.0.0 test/spell_checking/test_pattern_key_name_check.rb
did_you_mean-1.6.3 test/spell_checking/test_pattern_key_name_check.rb
did_you_mean-1.6.2 test/spell_checking/test_pattern_key_name_check.rb