<commit_before>require 'spec_helper'

describe Whoops::SearchParser do
  let(:sp){ Whoops::SearchParser.new("test") }
  
  describe "#parse_line" do
    it "provides a key, method, and value when present" do
      parsed = sp.parse_line('details.backtrace#in ["Test"]')
      parsed[:key].should == "details.backtrace".to_sym
      parsed[:method].should == :in
      parsed[:value].should  == ["Test"]
    end
  end
  
  describe "#parse_value" do
    it "handles numeric and string values in arrays" do
      sp.parse_value('[1,"2",4]').should == [1,'2',4]
    end
  end
end<commit_msg>using json to handle value part<commit_after>require 'spec_helper'

describe Whoops::SearchParser do
  let(:search_parser){ Whoops::SearchParser.new("test") }
  
  describe "#parse_line" do
    it "provides a key, method, and value when present" do
      parsed = search_parser.parse_line('details.backtrace#in ["Test"]')
      parsed[:key].should == "details.backtrace".to_sym
      parsed[:method].should == :in
      parsed[:value].should  == ["Test"]
    end
  end
  
  describe "#parse_value" do
    it "handles numeric and string values in arrays" do
      search_parser.parse_value('[1,"2",4]').should == [1,'2',4]
    end
    
    it "handles hashes" do
      search_parser.parse_value('{"1":3, "a":3, a:"test"}').should == {
        1 => 3,
        'a' => 3,
        'a' => 'test'
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.15609408410548825, 'fraction_numerical': 0.012829650748396294, 'mean_word_length': 3.2416918429003023, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 6, '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': '1775113', 'n_tokens_mistral': 469, 'n_tokens_neox': 470, 'n_words': 114}