spec/request_spec.rb in wvanbergen-request-log-analyzer-1.0.1 vs spec/request_spec.rb in wvanbergen-request-log-analyzer-1.0.2
- old
+ new
@@ -1,80 +1,72 @@
require File.dirname(__FILE__) + '/spec_helper'
-describe RequestLogAnalyzer::Request, :single_line do
+describe RequestLogAnalyzer::Request, :incomplete_request do
include RequestLogAnalyzerSpecHelper
before(:each) do
- @single_line_request = RequestLogAnalyzer::Request.new(spec_format)
- @single_line_request << { :line_type => :test, :lineno => 1, :test_capture => 'awesome!' }
+ @incomplete_request = RequestLogAnalyzer::Request.new(spec_format)
+ @incomplete_request << { :line_type => :test, :lineno => 1, :test_capture => 'awesome!' }
end
- it "should include the file format module" do
- (class << @single_line_request; self; end).ancestors.include?(TestFileFormat)
- end
-
it "should be single if only one line has been added" do
- @single_line_request.should be_single_line
- @single_line_request.should_not be_empty
- @single_line_request.should_not be_combined
+ @incomplete_request.should_not be_empty
end
it "should not be a completed request" do
- @single_line_request.should_not be_completed
+ @incomplete_request.should_not be_completed
end
it "should take the line type of the first line as global line_type" do
- @single_line_request.line_type.should == :test
- @single_line_request.should =~ :test
+ @incomplete_request.lines[0][:line_type].should == :test
+ @incomplete_request.should =~ :test
end
it "should return the first field value" do
- @single_line_request[:test_capture].should == 'awesome!'
+ @incomplete_request[:test_capture].should == 'awesome!'
end
it "should return nil if no such field is present" do
- @single_line_request[:nonexisting].should be_nil
+ @incomplete_request[:nonexisting].should be_nil
end
end
-describe RequestLogAnalyzer::Request, :combined do
+describe RequestLogAnalyzer::Request, :completed_request do
include RequestLogAnalyzerSpecHelper
before(:each) do
- @combined_request = RequestLogAnalyzer::Request.new(spec_format)
- @combined_request << { :line_type => :first, :lineno => 1, :name => 'first line!' }
- @combined_request << { :line_type => :test, :lineno => 4, :test_capture => 'testing' }
- @combined_request << { :line_type => :test, :lineno => 7, :test_capture => 'testing some more' }
- @combined_request << { :line_type => :last, :lineno => 10, :time => 0.03 }
+ @completed_request = RequestLogAnalyzer::Request.new(spec_format)
+ @completed_request << { :line_type => :first, :lineno => 1, :name => 'first line!' }
+ @completed_request << { :line_type => :test, :lineno => 4, :test_capture => 'testing' }
+ @completed_request << { :line_type => :test, :lineno => 7, :test_capture => 'testing some more' }
+ @completed_request << { :line_type => :last, :lineno => 10, :time => 0.03 }
end
- it "should be a combined request when more lines are added" do
- @combined_request.should be_combined
- @combined_request.should_not be_single_line
- @combined_request.should_not be_empty
+ it "should not be empty when multiple liness are added" do
+ @completed_request.should_not be_empty
end
it "should be a completed request" do
- @combined_request.should be_completed
+ @completed_request.should be_completed
end
it "should recognize all line types" do
- [:first, :test, :last].each { |type| @combined_request.should =~ type }
+ [:first, :test, :last].each { |type| @completed_request.should =~ type }
end
it "should detect the correct field value" do
- @combined_request[:name].should == 'first line!'
- @combined_request[:time].should == 0.03
+ @completed_request[:name].should == 'first line!'
+ @completed_request[:time].should == 0.03
end
it "should detect the first matching field value" do
- @combined_request.first(:test_capture).should == 'testing'
+ @completed_request.first(:test_capture).should == 'testing'
end
it "should detect the every matching field value" do
- @combined_request.every(:test_capture).should == ['testing', "testing some more"]
+ @completed_request.every(:test_capture).should == ['testing', "testing some more"]
end
end
\ No newline at end of file