request-log-analyzer 1.13.1 → 1.13.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/bin/console +17 -0
  4. data/lib/cli/command_line_arguments.rb +29 -36
  5. data/lib/cli/database_console.rb +1 -3
  6. data/lib/cli/database_console_init.rb +11 -11
  7. data/lib/cli/progressbar.rb +30 -32
  8. data/lib/cli/tools.rb +20 -23
  9. data/lib/request_log_analyzer.rb +8 -8
  10. data/lib/request_log_analyzer/aggregator.rb +4 -7
  11. data/lib/request_log_analyzer/aggregator/database_inserter.rb +10 -13
  12. data/lib/request_log_analyzer/aggregator/echo.rb +5 -7
  13. data/lib/request_log_analyzer/aggregator/summarizer.rb +15 -18
  14. data/lib/request_log_analyzer/class_level_inheritable_attributes.rb +23 -0
  15. data/lib/request_log_analyzer/controller.rb +36 -42
  16. data/lib/request_log_analyzer/database.rb +4 -6
  17. data/lib/request_log_analyzer/database/base.rb +39 -41
  18. data/lib/request_log_analyzer/database/connection.rb +8 -10
  19. data/lib/request_log_analyzer/database/request.rb +1 -3
  20. data/lib/request_log_analyzer/database/source.rb +0 -2
  21. data/lib/request_log_analyzer/database/warning.rb +4 -6
  22. data/lib/request_log_analyzer/file_format.rb +46 -49
  23. data/lib/request_log_analyzer/file_format/amazon_s3.rb +15 -19
  24. data/lib/request_log_analyzer/file_format/apache.rb +42 -45
  25. data/lib/request_log_analyzer/file_format/delayed_job.rb +13 -15
  26. data/lib/request_log_analyzer/file_format/delayed_job2.rb +9 -11
  27. data/lib/request_log_analyzer/file_format/delayed_job21.rb +9 -11
  28. data/lib/request_log_analyzer/file_format/delayed_job3.rb +5 -8
  29. data/lib/request_log_analyzer/file_format/delayed_job4.rb +5 -8
  30. data/lib/request_log_analyzer/file_format/haproxy.rb +44 -48
  31. data/lib/request_log_analyzer/file_format/merb.rb +13 -17
  32. data/lib/request_log_analyzer/file_format/mysql.rb +21 -25
  33. data/lib/request_log_analyzer/file_format/nginx.rb +0 -2
  34. data/lib/request_log_analyzer/file_format/oink.rb +30 -31
  35. data/lib/request_log_analyzer/file_format/postgresql.rb +11 -15
  36. data/lib/request_log_analyzer/file_format/rack.rb +0 -2
  37. data/lib/request_log_analyzer/file_format/rails.rb +100 -104
  38. data/lib/request_log_analyzer/file_format/rails3.rb +19 -23
  39. data/lib/request_log_analyzer/file_format/rails_development.rb +0 -1
  40. data/lib/request_log_analyzer/file_format/w3c.rb +16 -18
  41. data/lib/request_log_analyzer/filter.rb +0 -2
  42. data/lib/request_log_analyzer/filter/anonymize.rb +4 -7
  43. data/lib/request_log_analyzer/filter/field.rb +3 -6
  44. data/lib/request_log_analyzer/filter/timespan.rb +2 -6
  45. data/lib/request_log_analyzer/line_definition.rb +16 -19
  46. data/lib/request_log_analyzer/log_processor.rb +10 -14
  47. data/lib/request_log_analyzer/mailer.rb +9 -12
  48. data/lib/request_log_analyzer/output.rb +12 -14
  49. data/lib/request_log_analyzer/output/fixed_width.rb +21 -28
  50. data/lib/request_log_analyzer/output/html.rb +11 -14
  51. data/lib/request_log_analyzer/request.rb +53 -33
  52. data/lib/request_log_analyzer/source.rb +2 -5
  53. data/lib/request_log_analyzer/source/log_parser.rb +9 -16
  54. data/lib/request_log_analyzer/tracker.rb +10 -12
  55. data/lib/request_log_analyzer/tracker/duration.rb +4 -6
  56. data/lib/request_log_analyzer/tracker/frequency.rb +9 -11
  57. data/lib/request_log_analyzer/tracker/hourly_spread.rb +8 -11
  58. data/lib/request_log_analyzer/tracker/numeric_value.rb +40 -44
  59. data/lib/request_log_analyzer/tracker/timespan.rb +5 -8
  60. data/lib/request_log_analyzer/tracker/traffic.rb +8 -10
  61. data/lib/request_log_analyzer/version.rb +1 -1
  62. data/request-log-analyzer.gemspec +6 -6
  63. data/spec/integration/command_line_usage_spec.rb +33 -33
  64. data/spec/integration/mailer_spec.rb +181 -185
  65. data/spec/integration/munin_plugins_rails_spec.rb +20 -20
  66. data/spec/integration/scout_spec.rb +40 -41
  67. data/spec/lib/helpers.rb +8 -9
  68. data/spec/lib/macros.rb +2 -4
  69. data/spec/lib/matchers.rb +20 -25
  70. data/spec/lib/mocks.rb +10 -11
  71. data/spec/lib/testing_format.rb +8 -10
  72. data/spec/spec_helper.rb +5 -1
  73. data/spec/unit/aggregator/database_inserter_spec.rb +23 -23
  74. data/spec/unit/aggregator/summarizer_spec.rb +7 -7
  75. data/spec/unit/controller/controller_spec.rb +14 -14
  76. data/spec/unit/controller/log_processor_spec.rb +3 -3
  77. data/spec/unit/database/base_class_spec.rb +36 -37
  78. data/spec/unit/database/connection_spec.rb +10 -10
  79. data/spec/unit/database/database_spec.rb +11 -11
  80. data/spec/unit/file_format/amazon_s3_format_spec.rb +66 -62
  81. data/spec/unit/file_format/apache_format_spec.rb +57 -52
  82. data/spec/unit/file_format/common_regular_expressions_spec.rb +18 -21
  83. data/spec/unit/file_format/delayed_job21_format_spec.rb +22 -16
  84. data/spec/unit/file_format/delayed_job2_format_spec.rb +22 -16
  85. data/spec/unit/file_format/delayed_job3_format_spec.rb +14 -10
  86. data/spec/unit/file_format/delayed_job4_format_spec.rb +14 -10
  87. data/spec/unit/file_format/delayed_job_format_spec.rb +12 -12
  88. data/spec/unit/file_format/file_format_api_spec.rb +19 -19
  89. data/spec/unit/file_format/format_autodetection_spec.rb +7 -7
  90. data/spec/unit/file_format/haproxy_format_spec.rb +53 -49
  91. data/spec/unit/file_format/inheritance_spec.rb +13 -0
  92. data/spec/unit/file_format/line_definition_spec.rb +35 -33
  93. data/spec/unit/file_format/merb_format_spec.rb +13 -11
  94. data/spec/unit/file_format/mysql_format_spec.rb +24 -24
  95. data/spec/unit/file_format/oink_format_spec.rb +29 -29
  96. data/spec/unit/file_format/postgresql_format_spec.rb +9 -9
  97. data/spec/unit/file_format/rack_format_spec.rb +36 -31
  98. data/spec/unit/file_format/rails3_format_spec.rb +46 -46
  99. data/spec/unit/file_format/rails_format_spec.rb +52 -53
  100. data/spec/unit/file_format/w3c_format_spec.rb +27 -24
  101. data/spec/unit/filter/anonymize_filter_spec.rb +7 -7
  102. data/spec/unit/filter/field_filter_spec.rb +26 -26
  103. data/spec/unit/filter/filter_spec.rb +4 -4
  104. data/spec/unit/filter/timespan_filter_spec.rb +22 -22
  105. data/spec/unit/mailer_spec.rb +21 -21
  106. data/spec/unit/request_spec.rb +29 -29
  107. data/spec/unit/source/log_parser_spec.rb +5 -5
  108. data/spec/unit/tracker/duration_tracker_spec.rb +23 -23
  109. data/spec/unit/tracker/frequency_tracker_spec.rb +29 -30
  110. data/spec/unit/tracker/hourly_spread_spec.rb +35 -35
  111. data/spec/unit/tracker/numeric_value_tracker_spec.rb +71 -72
  112. data/spec/unit/tracker/timespan_tracker_spec.rb +31 -31
  113. data/spec/unit/tracker/tracker_api_spec.rb +43 -44
  114. data/spec/unit/tracker/traffic_tracker_spec.rb +7 -7
  115. metadata +38 -35
@@ -3,64 +3,64 @@ require 'spec_helper'
3
3
  describe RequestLogAnalyzer::Filter::Field, 'string in accept mode' do
4
4
 
5
5
  before(:each) do
6
- @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, :field => :test, :value => 'test', :mode => :select)
6
+ @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, field: :test, value: 'test', mode: :select)
7
7
  end
8
8
 
9
- it "should reject a request if the field value does not match" do
10
- @filter.filter(request(:test => 'not test')).should be_nil
9
+ it 'should reject a request if the field value does not match' do
10
+ @filter.filter(request(test: 'not test')).should be_nil
11
11
  end
12
12
 
13
- it "should reject a request if the field name does not match" do
14
- @filter.filter(request(:testing => 'test')).should be_nil
13
+ it 'should reject a request if the field name does not match' do
14
+ @filter.filter(request(testing: 'test')).should be_nil
15
15
  end
16
16
 
17
- it "should accept a request if the both name and value match" do
18
- @filter.filter(request(:test => 'test')).should_not be_nil
17
+ it 'should accept a request if the both name and value match' do
18
+ @filter.filter(request(test: 'test')).should_not be_nil
19
19
  end
20
20
 
21
- it "should accept a request if the value is not the first value" do
22
- @filter.filter(request([{:test => 'ignore'}, {:test => 'test'}])).should_not be_nil
21
+ it 'should accept a request if the value is not the first value' do
22
+ @filter.filter(request([{ test: 'ignore' }, { test: 'test' }])).should_not be_nil
23
23
  end
24
24
  end
25
25
 
26
26
  describe RequestLogAnalyzer::Filter::Field, 'string in reject mode' do
27
27
 
28
28
  before(:each) do
29
- @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, :field => :test, :value => 'test', :mode => :reject)
29
+ @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, field: :test, value: 'test', mode: :reject)
30
30
  end
31
31
 
32
- it "should accept a request if the field value does not match" do
33
- @filter.filter(request(:test => 'not test')).should_not be_nil
32
+ it 'should accept a request if the field value does not match' do
33
+ @filter.filter(request(test: 'not test')).should_not be_nil
34
34
  end
35
35
 
36
- it "should accept a request if the field name does not match" do
37
- @filter.filter(request(:testing => 'test')).should_not be_nil
36
+ it 'should accept a request if the field name does not match' do
37
+ @filter.filter(request(testing: 'test')).should_not be_nil
38
38
  end
39
39
 
40
- it "should reject a request if the both name and value match" do
41
- @filter.filter(request(:test => 'test')).should be_nil
40
+ it 'should reject a request if the both name and value match' do
41
+ @filter.filter(request(test: 'test')).should be_nil
42
42
  end
43
43
 
44
- it "should reject a request if the value is not the first value" do
45
- @filter.filter(request([{:test => 'ignore'}, {:test => 'test'}])).should be_nil
44
+ it 'should reject a request if the value is not the first value' do
45
+ @filter.filter(request([{ test: 'ignore' }, { test: 'test' }])).should be_nil
46
46
  end
47
47
  end
48
48
 
49
49
  describe RequestLogAnalyzer::Filter::Field, 'regexp in accept mode' do
50
50
 
51
51
  before(:each) do
52
- @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, :field => :test, :value => '/test/', :mode => :select)
52
+ @filter = RequestLogAnalyzer::Filter::Field.new(testing_format, field: :test, value: '/test/', mode: :select)
53
53
  end
54
54
 
55
- it "should reject a request if the field value does not match" do
56
- @filter.filter(request(:test => 'a working test')).should_not be_nil
55
+ it 'should reject a request if the field value does not match' do
56
+ @filter.filter(request(test: 'a working test')).should_not be_nil
57
57
  end
58
58
 
59
- it "should reject a request if the field name does not match" do
60
- @filter.filter(request(:testing => 'test')).should be_nil
59
+ it 'should reject a request if the field name does not match' do
60
+ @filter.filter(request(testing: 'test')).should be_nil
61
61
  end
62
62
 
63
- it "should accept a request if the value is not the first value" do
64
- @filter.filter(request([{:test => 'ignore'}, {:test => 'testing 123'}])).should_not be_nil
63
+ it 'should accept a request if the value is not the first value' do
64
+ @filter.filter(request([{ test: 'ignore' }, { test: 'testing 123' }])).should_not be_nil
65
65
  end
66
- end
66
+ end
@@ -6,12 +6,12 @@ describe RequestLogAnalyzer::Filter::Base, 'base filter' do
6
6
  @filter = RequestLogAnalyzer::Filter::Base.new(testing_format)
7
7
  end
8
8
 
9
- it "should return everything" do
10
- @filter.filter(request(:ip => '123.123.123.123'))[:ip].should eql('123.123.123.123')
9
+ it 'should return everything' do
10
+ @filter.filter(request(ip: '123.123.123.123'))[:ip].should eql('123.123.123.123')
11
11
  end
12
12
 
13
- it "should return nil on nil request" do
13
+ it 'should return nil on nil request' do
14
14
  @filter.filter(nil).should be_nil
15
15
  end
16
16
 
17
- end
17
+ end
@@ -3,56 +3,56 @@ require 'spec_helper'
3
3
  describe RequestLogAnalyzer::Filter::Timespan, 'both before and after' do
4
4
 
5
5
  before(:each) do
6
- @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, :after => DateTime.parse('2009-01-01'), :before => DateTime.parse('2009-02-02'))
6
+ @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, after: DateTime.parse('2009-01-01'), before: DateTime.parse('2009-02-02'))
7
7
  end
8
8
 
9
- it "should reject a request before the after date" do
10
- @filter.filter(request(:timestamp => 20081212000000)).should be_nil
9
+ it 'should reject a request before the after date' do
10
+ @filter.filter(request(timestamp: 20_081_212_000_000)).should be_nil
11
11
  end
12
12
 
13
- it "should reject a request after the before date" do
14
- @filter.filter(request(:timestamp => 20090303000000)).should be_nil
13
+ it 'should reject a request after the before date' do
14
+ @filter.filter(request(timestamp: 20_090_303_000_000)).should be_nil
15
15
  end
16
16
 
17
- it "should accept a request between the after and before dates" do
18
- @filter.filter(request(:timestamp => 20090102000000)).should_not be_nil
17
+ it 'should accept a request between the after and before dates' do
18
+ @filter.filter(request(timestamp: 20_090_102_000_000)).should_not be_nil
19
19
  end
20
20
  end
21
21
 
22
22
  describe RequestLogAnalyzer::Filter::Timespan, 'only before' do
23
23
 
24
24
  before(:each) do
25
- @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, :before => DateTime.parse('2009-02-02'))
25
+ @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, before: DateTime.parse('2009-02-02'))
26
26
  end
27
27
 
28
- it "should accept a request before the after date" do
29
- @filter.filter(request(:timestamp => 20081212000000)).should_not be_nil
28
+ it 'should accept a request before the after date' do
29
+ @filter.filter(request(timestamp: 20_081_212_000_000)).should_not be_nil
30
30
  end
31
31
 
32
- it "should reject a request after the before date" do
33
- @filter.filter(request(:timestamp => 20090303000000)).should be_nil
32
+ it 'should reject a request after the before date' do
33
+ @filter.filter(request(timestamp: 20_090_303_000_000)).should be_nil
34
34
  end
35
35
 
36
- it "should accept a request between the after and before dates" do
37
- @filter.filter(request(:timestamp => 20090102000000)).should_not be_nil
36
+ it 'should accept a request between the after and before dates' do
37
+ @filter.filter(request(timestamp: 20_090_102_000_000)).should_not be_nil
38
38
  end
39
39
  end
40
40
 
41
41
  describe RequestLogAnalyzer::Filter::Timespan, 'only after' do
42
42
 
43
43
  before(:each) do
44
- @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, :after => DateTime.parse('2009-01-01'))
44
+ @filter = RequestLogAnalyzer::Filter::Timespan.new(testing_format, after: DateTime.parse('2009-01-01'))
45
45
  end
46
46
 
47
- it "should reject a request before the after date" do
48
- @filter.filter(request(:timestamp => 20081212000000)).should be_nil
47
+ it 'should reject a request before the after date' do
48
+ @filter.filter(request(timestamp: 20_081_212_000_000)).should be_nil
49
49
  end
50
50
 
51
- it "should accept a request after the before date" do
52
- @filter.filter(request(:timestamp => 20090303000000)).should_not be_nil
51
+ it 'should accept a request after the before date' do
52
+ @filter.filter(request(timestamp: 20_090_303_000_000)).should_not be_nil
53
53
  end
54
54
 
55
- it "should accept a request between the after and before dates" do
56
- @filter.filter(request(:timestamp => 20090102000000)).should_not be_nil
55
+ it 'should accept a request between the after and before dates' do
56
+ @filter.filter(request(timestamp: 20_090_102_000_000)).should_not be_nil
57
57
  end
58
- end
58
+ end
@@ -2,41 +2,41 @@ require 'spec_helper'
2
2
 
3
3
  describe RequestLogAnalyzer::Mailer, 'mailer' do
4
4
 
5
- it "should initialize correctly" do
6
- @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', :debug => true)
7
- @mailer.host.should eql("localhost")
5
+ it 'should initialize correctly' do
6
+ @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', debug: true)
7
+ @mailer.host.should eql('localhost')
8
8
  @mailer.port.should eql(25)
9
9
  end
10
-
11
- it "should allow alternate port settings" do
12
- @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost:2525', :debug => true)
13
- @mailer.host.should eql("localhost")
14
- @mailer.port.should eql("2525")
10
+
11
+ it 'should allow alternate port settings' do
12
+ @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost:2525', debug: true)
13
+ @mailer.host.should eql('localhost')
14
+ @mailer.port.should eql('2525')
15
15
  end
16
16
 
17
- it "should store printed data" do
18
- @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', :debug => true)
17
+ it 'should store printed data' do
18
+ @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', debug: true)
19
19
 
20
20
  @mailer << 'test1'
21
21
  @mailer.puts 'test2'
22
-
23
- @mailer.data.should eql(['test1', 'test2'])
22
+
23
+ @mailer.data.should eql(%w(test1 test2))
24
24
  end
25
25
 
26
- it "should send mail" do
27
- @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', :debug => true)
26
+ it 'should send mail' do
27
+ @mailer = RequestLogAnalyzer::Mailer.new('alfa@beta.com', 'localhost', debug: true)
28
28
 
29
29
  @mailer << 'test1'
30
30
  @mailer.puts 'test2'
31
31
 
32
32
  mail = @mailer.mail
33
-
34
- mail[0].should include("contact@railsdoctors.com")
35
- mail[0].should include("test1")
36
- mail[0].should include("test2")
37
33
 
38
- mail[1].should include("contact@railsdoctors.com")
39
- mail[2].should include("alfa@beta.com")
34
+ mail[0].should include('contact@railsdoctors.com')
35
+ mail[0].should include('test1')
36
+ mail[0].should include('test2')
37
+
38
+ mail[1].should include('contact@railsdoctors.com')
39
+ mail[2].should include('alfa@beta.com')
40
40
  end
41
41
 
42
- end
42
+ end
@@ -6,34 +6,34 @@ describe RequestLogAnalyzer::Request do
6
6
  @request = testing_format.request
7
7
  end
8
8
 
9
- it "should be empty without any captured lines in it" do
9
+ it 'should be empty without any captured lines in it' do
10
10
  @request.should be_empty
11
11
  end
12
12
 
13
13
  context :incomplete do
14
14
 
15
15
  before(:each) do
16
- @request << { :line_type => :test, :lineno => 1, :test_capture => 'awesome!' }
16
+ @request << { line_type: :test, lineno: 1, test_capture: 'awesome!' }
17
17
  end
18
18
 
19
- it "should be single if only one line has been added" do
19
+ it 'should be single if only one line has been added' do
20
20
  @request.should_not be_empty
21
21
  end
22
22
 
23
- it "should not be a completed request" do
23
+ it 'should not be a completed request' do
24
24
  @request.should_not be_completed
25
25
  end
26
26
 
27
- it "should take the line type of the first line as global line_type" do
27
+ it 'should take the line type of the first line as global line_type' do
28
28
  @request.lines[0][:line_type].should == :test
29
29
  @request.should =~ :test
30
30
  end
31
31
 
32
- it "should return the first field value" do
32
+ it 'should return the first field value' do
33
33
  @request[:test_capture].should == 'awesome!'
34
34
  end
35
35
 
36
- it "should return nil if no such field is present" do
36
+ it 'should return nil if no such field is present' do
37
37
  @request[:nonexisting].should be_nil
38
38
  end
39
39
  end
@@ -41,70 +41,70 @@ describe RequestLogAnalyzer::Request do
41
41
  context :completed do
42
42
 
43
43
  before(:each) do
44
- @request << { :line_type => :first, :lineno => 1, :name => 'first line!' }
45
- @request << { :line_type => :test, :lineno => 4, :test_capture => 'testing' }
46
- @request << { :line_type => :test, :lineno => 7, :test_capture => 'testing some more' }
47
- @request << { :line_type => :last, :lineno => 10, :time => 0.03 }
44
+ @request << { line_type: :first, lineno: 1, name: 'first line!' }
45
+ @request << { line_type: :test, lineno: 4, test_capture: 'testing' }
46
+ @request << { line_type: :test, lineno: 7, test_capture: 'testing some more' }
47
+ @request << { line_type: :last, lineno: 10, time: 0.03 }
48
48
  end
49
49
 
50
- it "should not be empty when multiple liness are added" do
50
+ it 'should not be empty when multiple liness are added' do
51
51
  @request.should_not be_empty
52
52
  end
53
53
 
54
- it "should be a completed request" do
54
+ it 'should be a completed request' do
55
55
  @request.should be_completed
56
56
  end
57
57
 
58
- it "should recognize all line types" do
58
+ it 'should recognize all line types' do
59
59
  [:first, :test, :last].each { |type| @request.should =~ type }
60
60
  end
61
61
 
62
- it "should detect the correct field value" do
62
+ it 'should detect the correct field value' do
63
63
  @request[:name].should == 'first line!'
64
64
  @request[:time].should == 0.03
65
65
  end
66
66
 
67
- it "should detect the first matching field value" do
67
+ it 'should detect the first matching field value' do
68
68
  @request.first(:test_capture).should == 'testing'
69
69
  end
70
70
 
71
- it "should detect the every matching field value" do
72
- @request.every(:test_capture).should == ['testing', "testing some more"]
71
+ it 'should detect the every matching field value' do
72
+ @request.every(:test_capture).should == ['testing', 'testing some more']
73
73
  end
74
74
 
75
- it "should set the first_lineno for a request to the lowest lineno encountered" do
75
+ it 'should set the first_lineno for a request to the lowest lineno encountered' do
76
76
  @request.first_lineno.should eql(1)
77
77
  end
78
78
 
79
- it "should set the first_lineno for a request if a line with a lower lineno is added" do
80
- @request << { :line_type => :test, :lineno => 0 }
79
+ it 'should set the first_lineno for a request if a line with a lower lineno is added' do
80
+ @request << { line_type: :test, lineno: 0 }
81
81
  @request.first_lineno.should eql(0)
82
82
  end
83
83
 
84
- it "should set the last_lineno for a request to the highest encountered lineno" do
84
+ it 'should set the last_lineno for a request to the highest encountered lineno' do
85
85
  @request.last_lineno.should eql(10)
86
86
  end
87
87
 
88
- it "should not set the last_lineno for a request if a line with a lower lineno is added" do
89
- @request << { :line_type => :test, :lineno => 7 }
88
+ it 'should not set the last_lineno for a request if a line with a lower lineno is added' do
89
+ @request << { line_type: :test, lineno: 7 }
90
90
  @request.last_lineno.should eql(10)
91
91
  end
92
92
 
93
- it "should not have a timestamp if no such field is captured" do
93
+ it 'should not have a timestamp if no such field is captured' do
94
94
  @request.timestamp.should be_nil
95
95
  end
96
96
 
97
- it "should set return a timestamp field if such a field is captured" do
98
- @request << { :line_type => :first, :lineno => 1, :name => 'first line!', :timestamp => Time.now}
97
+ it 'should set return a timestamp field if such a field is captured' do
98
+ @request << { line_type: :first, lineno: 1, name: 'first line!', timestamp: Time.now }
99
99
  @request.timestamp.should_not be_nil
100
100
  end
101
101
  end
102
102
 
103
103
  context 'single line' do
104
104
  # combined is both a header and a footer line
105
- before(:each) { @request << { :line_type => :combined, :lineno => 1 } }
105
+ before(:each) { @request << { line_type: :combined, lineno: 1 } }
106
106
 
107
- it "should be a completed request if the line is both header and footer" do
107
+ it 'should be a completed request if the line is both header and footer' do
108
108
  @request.should be_completed
109
109
  end
110
110
  end
@@ -16,13 +16,13 @@ describe RequestLogAnalyzer::Source::LogParser do
16
16
 
17
17
  it "should set the :source for every parsed line" do
18
18
  @log_parser.parse_file(log_fixture(:rails_22)) do |request|
19
- request.lines.all? { |line| line[:source] == log_fixture(:rails_22) }.should be_true
19
+ request.lines.all? { |line| line[:source] == log_fixture(:rails_22) }.should == true
20
20
  end
21
21
  end
22
22
 
23
23
  it "should set the :lineno for every parsed line" do
24
24
  @log_parser.parse_file(log_fixture(:rails_22)) do |request|
25
- request.lines.all? { |line| line.has_key?(:lineno) }.should be_true
25
+ request.lines.all? { |line| line.has_key?(:lineno) }.should == true
26
26
  end
27
27
  end
28
28
 
@@ -39,7 +39,7 @@ describe RequestLogAnalyzer::Source::LogParser do
39
39
 
40
40
  it "should parse all request values when spanned over multiple files" do
41
41
  @log_parser.parse_files([log_fixture(:multiple_files_1), log_fixture(:multiple_files_2)]) do |request|
42
- request.lines.should have(4).items
42
+ request.lines.length.should be 4
43
43
  request[:request_no].should == 1
44
44
  request[:test_capture].should == "Testing is amazing" # Note the custom converter
45
45
  end
@@ -113,7 +113,7 @@ describe RequestLogAnalyzer::Source::LogParser do
113
113
  @log_parser.parsed_lines.should > 0
114
114
  end
115
115
  end
116
-
116
+
117
117
  if `which unzip` != ""
118
118
  it "should parse a rails zipped log file" do
119
119
  @log_parser.should_receive(:handle_request).once
@@ -122,4 +122,4 @@ describe RequestLogAnalyzer::Source::LogParser do
122
122
  end
123
123
  end
124
124
  end
125
- end
125
+ end
@@ -5,53 +5,53 @@ describe RequestLogAnalyzer::Tracker::Duration do
5
5
  describe '#report' do
6
6
 
7
7
  before(:each) do
8
- @tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :value => :duration)
8
+ @tracker = RequestLogAnalyzer::Tracker::Duration.new(category: :category, value: :duration)
9
9
  @tracker.prepare
10
10
  end
11
11
 
12
- it "should generate a report without errors when one category is present" do
13
- @tracker.update(request(:category => 'a', :duration => 0.2))
12
+ it 'should generate a report without errors when one category is present' do
13
+ @tracker.update(request(category: 'a', duration: 0.2))
14
14
  lambda { @tracker.report(mock_output) }.should_not raise_error
15
15
  end
16
16
 
17
- it "should generate a report without errors when no category is present" do
17
+ it 'should generate a report without errors when no category is present' do
18
18
  lambda { @tracker.report(mock_output) }.should_not raise_error
19
19
  end
20
20
 
21
- it "should generate a report without errors when multiple categories are present" do
22
- @tracker.update(request(:category => 'a', :duration => 0.2))
23
- @tracker.update(request(:category => 'b', :duration => 0.2))
21
+ it 'should generate a report without errors when multiple categories are present' do
22
+ @tracker.update(request(category: 'a', duration: 0.2))
23
+ @tracker.update(request(category: 'b', duration: 0.2))
24
24
  lambda { @tracker.report(mock_output) }.should_not raise_error
25
25
  end
26
26
 
27
- it "should generate a report with arrays of durations are present" do
28
- @tracker.update(request(:category => 'a', :duration => [0.1, 0.2]))
29
- @tracker.update(request(:category => 'a', :duration => [0.2, 0.3]))
27
+ it 'should generate a report with arrays of durations are present' do
28
+ @tracker.update(request(category: 'a', duration: [0.1, 0.2]))
29
+ @tracker.update(request(category: 'a', duration: [0.2, 0.3]))
30
30
  lambda { @tracker.report(mock_output) }.should_not raise_error
31
- @tracker.to_yaml_object['a'].should include(:min => 0.1, :hits => 4, :max => 0.3, :mean => 0.2, :sum => 0.8)
31
+ @tracker.to_yaml_object['a'].should include(min: 0.1, hits: 4, max: 0.3, mean: 0.2, sum: 0.8)
32
32
  end
33
33
 
34
- it "should generate a YAML output" do
35
- @tracker.update(request(:category => 'a', :duration => 0.2))
36
- @tracker.update(request(:category => 'b', :duration => 0.2))
37
- @tracker.to_yaml_object.keys.should =~ ['a', 'b']
38
- @tracker.to_yaml_object['a'].should include(:min => 0.2, :hits => 1, :max => 0.2, :mean => 0.2, :sum => 0.2, :sum_of_squares => 0.0)
39
- @tracker.to_yaml_object['b'].should include(:min => 0.2, :hits => 1, :max => 0.2, :mean => 0.2, :sum => 0.2, :sum_of_squares => 0.0)
34
+ it 'should generate a YAML output' do
35
+ @tracker.update(request(category: 'a', duration: 0.2))
36
+ @tracker.update(request(category: 'b', duration: 0.2))
37
+ @tracker.to_yaml_object.keys.should =~ %w(a b)
38
+ @tracker.to_yaml_object['a'].should include(min: 0.2, hits: 1, max: 0.2, mean: 0.2, sum: 0.2, sum_of_squares: 0.0)
39
+ @tracker.to_yaml_object['b'].should include(min: 0.2, hits: 1, max: 0.2, mean: 0.2, sum: 0.2, sum_of_squares: 0.0)
40
40
  end
41
41
  end
42
-
42
+
43
43
  describe '#display_value' do
44
- before(:each) { @tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :value => :duration) }
45
-
46
- it "should only display seconds when time < 60" do
44
+ before(:each) { @tracker = RequestLogAnalyzer::Tracker::Duration.new(category: :category, value: :duration) }
45
+
46
+ it 'should only display seconds when time < 60' do
47
47
  @tracker.display_value(33.12).should == '33.12s'
48
48
  end
49
49
 
50
- it "should display minutes and wholeseconds when time > 60" do
50
+ it 'should display minutes and wholeseconds when time > 60' do
51
51
  @tracker.display_value(63.12).should == '1m03s'
52
52
  end
53
53
 
54
- it "should display minutes and wholeseconds when time > 60" do
54
+ it 'should display minutes and wholeseconds when time > 60' do
55
55
  @tracker.display_value(3601.12).should == '1h00m01s'
56
56
  end
57
57
  end