Sha256: b85db8a778eebeaf26d292c7a6291357a35326b60e51cf1224b785014bb57e90

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 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", error.to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
did_you_mean-1.6.1 test/spell_checking/test_pattern_key_name_check.rb