Sha256: 9fd21ba1d5f95f11cb8081854f5cf832f3c8b2b7fb90dc88d04c56a316c6f9b8
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe RequestLogAnalyzer::FileFormat::LineDefinition do before(:each) do @line_definition = RequestLogAnalyzer::FileFormat::LineDefinition.new(:test, { :teaser => /Testing /, :regexp => /Testing (\w+), tries\: (\d+)/, :captures => [{:what => :string}, {:tries => :integer}] }) end it "should return false on an unmatching line" do (@line_definition =~ "nonmatching").should be_false end it "should return false when only the teaser matches" do (@line_definition =~ "Testing LineDefinition").should be_false end it "should return a hash if the line matches" do (@line_definition =~ "Testing LineDefinition, tries: 123").should be_kind_of(Hash) end it "should return a hash with all captures set" do hash = @line_definition.matches("Testing LineDefinition, tries: 123") hash[:what].should == "LineDefinition" hash[:tries].should == 123 end it "should return a hash with :line_type set" do @line_definition.matches("Testing LineDefinition, tries: 123")[:line_type].should == :test end end
Version data entries
4 entries across 4 versions & 1 rubygems