Sha256: b5eb17facb07ad8c17a812439016cc70c87b350dcc3640892b75738a501c01d9
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
# encoding: utf-8 require "logstash/filters/parsers/yahoo" describe YahooQueryParser do parser = YahooQueryParser.new describe "match site name" do it "should match whatever the file extension" do country_extensions = ["fr", "com", "eu", "it", "hn", "co"] country_extensions.each do |extension| expect(parser.match("#{extension}.search.yahoo.#{extension}")).to be_truthy end end it "should match without country prefix" do expect(parser.match("search.yahoo.com")).to be_truthy end it "should not match if not yahoo" do expect(parser.match("search.yaboo.com")).to be_falsy end end describe "extract query" do it "should not return query when no query" do expect(parser.parse("/search?hl=fr")).to be_nil end it "should not return query when other api" do expect(parser.parse("/complete/search?p=kibana")).to be_nil end it "should return query when no other parameter" do expect(parser.parse("/search?p=kibana")).to eq("kibana") end it "should return query when other parameters afterwards" do expect(parser.parse("/search?p=kibana&hl=fr")).to eq("kibana") end it "should return query when other parameters before" do expect(parser.parse("/search?hl=fr&p=kibana")).to eq("kibana") end it "should return query when anchor" do expect(parser.parse("/search?hl=fr&p=kibana#p=toto")).to eq("kibana") end it "should return query without plus sign when multiple words" do expect(parser.parse("/search?hl=fr&p=kibana+4#p=toto")).to eq("kibana 4") end it "should handle utf 8 invalid characters" do expect(parser.parse("/search?p=\xFF+amazing\xFF+test\xFF")).to eq("amazing test") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logstash-filter-search-engine-2.0.0 | spec/filters/parsers/yahoo_spec.rb |