<commit_before># We can't use `require` or `load` because of the Bash preamble on the script.
source = File.read(File.expand_path("../../selecta", __FILE__))
preamble, source = source.split("#!ruby", 2)
eval(source)

#load File.expand_path("../../selecta", __FILE__)

describe World do
  let(:options) { Options.new(20) }
  let(:world) { World.blank(options, ["one", "two", "three"]) }

  it "selects the first choice by default" do
    world.selected_choice.should == "one"
  end

  describe "moving down the list" do
    it "moves down the list" do
      world.down.selected_choice.should == "two"
    end

    it "won't move past the end of the list" do
      world.down.down.down.down.selected_choice.should == "three"
    end

    it "won't move past the visible choice limit" do
      options = Options.new(2)
      world = World.blank(options, ["one", "two", "three"])
      world.down.down.down.selected_choice.should == "two"
    end

    it "moves down the filtered search results"
  end

  it "move up the list" do
    world.down.up.selected_choice.should == "one"
  end

  it "backspaces over characters" do
    world = self.world.append_search_string("e")
    world.query.should == "e"
    world = world.backspace
    world.query.should == ""
  end

  it "deletes words" do
    world.append_search_string("").delete_word.query.should == ""
    world.append_search_string("a").delete_word.query.should == ""
    world.append_search_string("a ").delete_word.query.should == ""
    world.append_search_string("a b").delete_word.query.should == "a "
    world.append_search_string("a b ").delete_word.query.should == "a "
    world.append_search_string(" a b").delete_word.query.should == " a "
  end

  describe "matching" do
    it "is fuzzy" do
      world.append_search_string("e").matches.should == ["one", "three"]
      world.append_search_string("oe").matches.should == ["one"]
    end

    it "is case insensitive" do
      world.append_search_string("OE").matches.should == ["one"]
    end

    it "matches punctuation" do
      world = World.blank(options, ["/! symbols $^"])
      world.append_search_string("/!$^").matches.should == ["/! symbols $^"]
    end
  end

  it "knows when it's done" do
    world.done?.should == false
    world.done.done?.should == true
  end
end<commit_msg>update specs for World -> Search<commit_after># We can't use `require` or `load` because of the Bash preamble on the script.
source = File.read(File.expand_path("../../selecta", __FILE__))
preamble, source = source.split("#!ruby", 2)
eval(source)

#load File.expand_path("../../selecta", __FILE__)

describe Search do
  let(:options) { Options.new(20) }
  let(:world) { Search.blank(options, ["one", "two", "three"]) }

  it "selects the first choice by default" do
    world.selected_choice.should == "one"
  end

  describe "moving down the list" do
    it "moves down the list" do
      world.down.selected_choice.should == "two"
    end

    it "won't move past the end of the list" do
      world.down.down.down.down.selected_choice.should == "three"
    end

    it "won't move past the visible choice limit" do
      options = Options.new(2)
      world = Search.blank(options, ["one", "two", "three"])
      world.down.down.down.selected_choice.should == "two"
    end

    it "moves down the filtered search results"
  end

  it "move up the list" do
    world.down.up.selected_choice.should == "one"
  end

  it "backspaces over characters" do
    world = self.world.append_search_string("e")
    world.query.should == "e"
    world = world.backspace
    world.query.should == ""
  end

  it "deletes words" do
    world.append_search_string("").delete_word.query.should == ""
    world.append_search_string("a").delete_word.query.should == ""
    world.append_search_string("a ").delete_word.query.should == ""
    world.append_search_string("a b").delete_word.query.should == "a "
    world.append_search_string("a b ").delete_word.query.should == "a "
    world.append_search_string(" a b").delete_word.query.should == " a "
  end

  describe "matching" do
    it "is fuzzy" do
      world.append_search_string("e").matches.should == ["one", "three"]
      world.append_search_string("oe").matches.should == ["one"]
    end

    it "is case insensitive" do
      world.append_search_string("OE").matches.should == ["one"]
    end

    it "matches punctuation" do
      world = Search.blank(options, ["/! symbols $^"])
      world.append_search_string("/!$^").matches.should == ["/! symbols $^"]
    end
  end

  it "knows when it's done" do
    world.done?.should == false
    world.done.done?.should == true
  end
end
{'fraction_non_alphanumeric': 0.1504634619530071, 'fraction_numerical': 0.0017245095925846087, 'mean_word_length': 3.300278035217794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3261491', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1473, 'n_words': 379}