Sha256: 2ca078f350b31612f4c26485c6bf9be306228a3f558510fb16b091e030ee7df1
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') class Lightning::CompletionTest < Test::Unit::TestCase context "Completion" do before(:each) { @key = 'blah'; Lightning.bolts[@key].stub!(:completions, :return=>%w{at ap blah}) Lightning.config[:complete_regex] = true } test "from script matches" do Lightning.config[:complete_regex] = false assert_arrays_equal %w{at ap}, Lightning::Completion.complete('cd-test a', @key) end test "for basic case matches" do Lightning.config[:complete_regex] = false @completion = Lightning::Completion.new('cd-test a', @key) assert_arrays_equal %w{at ap}, @completion.matches end test "with test flag matches" do Lightning.config[:complete_regex] = false @completion = Lightning::Completion.new('cd-test -test a', @key) assert_arrays_equal %w{at ap}, @completion.matches end test "with complete_regex on matches" do Lightning.config[:complete_regex] = true @completion = Lightning::Completion.new('cd-test *', @key) assert_arrays_equal %w{at ap blah}, @completion.matches end test "with invalid regex is rescued" do Lightning.config[:complete_regex] = true @completion = Lightning::Completion.new('cd-test []', @key) assert !@completion.matches.grep(/Error/).empty? end end test "blob_to_regex converts * to .*" do @lc = Lightning::Completion.new('blah', @key) assert_equal '.*a.*blah', @lc.blob_to_regex('*a*blah') end test "blob_to_regex doesn't modify .*" do @lc = Lightning::Completion.new('blah', @key) assert_equal '.*blah.*', @lc.blob_to_regex('.*blah.*') end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
cldwalker-lightning-0.2.0 | test/completion_test.rb |
lightning-0.2.1 | test/completion_test.rb |