summaryrefslogtreecommitdiff
path: root/test/did_you_mean/tree_spell/test_human_typo.rb
diff options
context:
space:
mode:
authorKevin Deisz <kevin.deisz@gmail.com>2019-10-29 10:08:37 -0400
committerYuki Nishijima <yk.nishijima@gmail.com>2019-11-30 21:08:19 -0500
commit171803d5d34feb1b4244ca81b9db0a7bc2171c85 (patch)
tree664ee644da144f28152097fbe5ea43329bfc0576 /test/did_you_mean/tree_spell/test_human_typo.rb
parenta2fc6a51dd2e1a153559038795e1e2509f9c6a94 (diff)
Promote did_you_mean to default gem
At the moment, there are some problems with regard to bundler + did_you_mean because of did_you_mean being a bundled gem. Since the vendored version of thor inside bundler and ruby itself explicitly requires did_you_mean, it can become difficult to load it when using Bundler.setup. See this issue: https://github.com/yuki24/did_you_mean/issues/117#issuecomment-482733159 for more details.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2689
Diffstat (limited to 'test/did_you_mean/tree_spell/test_human_typo.rb')
-rw-r--r--test/did_you_mean/tree_spell/test_human_typo.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/did_you_mean/tree_spell/test_human_typo.rb b/test/did_you_mean/tree_spell/test_human_typo.rb
new file mode 100644
index 0000000000..7ede9e393e
--- /dev/null
+++ b/test/did_you_mean/tree_spell/test_human_typo.rb
@@ -0,0 +1,24 @@
+require_relative '../helper'
+require_relative 'human_typo'
+
+class HumanTypoTest < Test::Unit::TestCase
+ def setup
+ @input = 'spec/services/anything_spec'
+ @sh = TreeSpell::HumanTypo.new(@input, lambda: 0.05)
+ @len = @input.length
+ end
+
+ def test_changes
+ # srand seed ensures all four actions are called
+ srand 247_696_449
+ sh = TreeSpell::HumanTypo.new(@input, lambda: 0.20)
+ word_error = sh.call
+ assert_equal word_error, 'spec/suervcieq/anythin_gpec'
+ end
+
+ def test_check_input
+ assert_raise(RuntimeError, "input length must be greater than 5 characters: tiny") do
+ TreeSpell::HumanTypo.new('tiny')
+ end
+ end
+end