beagle 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/beagle.rb +1 -1
- data/lib/beagle/cucumber/timed_formatter.rb +89 -0
- data/lib/beagle/examples.rb +1 -1
- data/lib/beagle/metrics.rb +1 -1
- data/lib/beagle/version.rb +1 -1
- data/lib/templates/cuke.rhtml +131 -0
- data/spec/beagle/examples_spec.rb +15 -0
- data/spec/beagle/metrics_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -0
- metadata +16 -8
data/lib/beagle.rb
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
module Beagle
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
|
5
|
+
class TimedFormatter
|
6
|
+
|
7
|
+
def initialize(step_mother, path_or_io, options)
|
8
|
+
@step_mother = step_mother
|
9
|
+
@path_or_io = path_or_io
|
10
|
+
@options = options
|
11
|
+
@scenarios = Hash.new{|h,k| h[k] = []}
|
12
|
+
end
|
13
|
+
|
14
|
+
def before_feature(feature)
|
15
|
+
@tags = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def before_feature_element(feature_element)
|
19
|
+
file = feature_element.feature.file
|
20
|
+
@scenarios[file] << {:name => feature_element.name, :line_number => 0, :time => 0, :count => 1, :tags => @tags.flatten.uniq}
|
21
|
+
|
22
|
+
case feature_element
|
23
|
+
when Cucumber::Ast::Scenario
|
24
|
+
@scenario = @scenarios[file].last
|
25
|
+
@scenario_outline = nil
|
26
|
+
when Cucumber::Ast::ScenarioOutline
|
27
|
+
@scenario_outline = @scenarios[file].last
|
28
|
+
@scenario = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def tag_name(name)
|
33
|
+
@tags << name
|
34
|
+
end
|
35
|
+
|
36
|
+
def scenario_name(keyword, name, file_colon_line, source_indent)
|
37
|
+
file, line_number = file_colon_line.split(':')
|
38
|
+
@scenarios[file].last[:line_number] = line_number
|
39
|
+
end
|
40
|
+
|
41
|
+
def before_steps(steps)
|
42
|
+
@start_time = Time.now
|
43
|
+
end
|
44
|
+
|
45
|
+
def after_steps(steps)
|
46
|
+
@scenario[:time] = (Time.now - @start_time) if @scenario
|
47
|
+
end
|
48
|
+
|
49
|
+
def before_examples(examples)
|
50
|
+
@examples = true
|
51
|
+
@start_time = Time.now
|
52
|
+
end
|
53
|
+
|
54
|
+
def after_examples(examples)
|
55
|
+
@scenario_outline[:time] = (Time.now - @start_time) if @scenario_outline
|
56
|
+
@examples = false
|
57
|
+
end
|
58
|
+
|
59
|
+
def after_outline_table(outline_table)
|
60
|
+
@scenario_outline[:count] = outline_table.example_rows.size
|
61
|
+
end
|
62
|
+
|
63
|
+
def after_features(features)
|
64
|
+
@times = []
|
65
|
+
@by_tag = Hash.new{|h,k| h[k] = []}
|
66
|
+
@scenarios.each do |file, scenarios|
|
67
|
+
scenarios.each do |scenario|
|
68
|
+
tags = scenario[:tags].empty? ? ['none'] : scenario[:tags]
|
69
|
+
tags.each do |tag|
|
70
|
+
@by_tag[tag] << {:scenario => scenario[:name], :file => file, :time => scenario[:time], :count => scenario[:count]}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
time = scenarios.inject(0) {|sum, scenario| sum + scenario[:time] }
|
74
|
+
count = scenarios.inject(0) {|sum, scenario| sum + scenario[:count] }
|
75
|
+
tags = scenarios.map {|scenario| scenario[:tags] }.flatten.uniq
|
76
|
+
@times << [file, count, tags, time, scenarios]
|
77
|
+
end
|
78
|
+
@times.sort! {|a,b| b[3] <=> a[3]}
|
79
|
+
out_dir = "#{Rails.root}/reports/cucumber"
|
80
|
+
template = File.read(File.expand_path('../../templates/cuke.rhtml', File.dirname(__FILE__)))
|
81
|
+
rhtml = ERB.new(template, nil, ">")
|
82
|
+
FileUtils.mkdir_p out_dir
|
83
|
+
outfile = "#{out_dir}/index.html"
|
84
|
+
FileUtils.rm_rf outfile
|
85
|
+
File.open(outfile, 'w') {|f| f.write(rhtml.result(binding)) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/beagle/examples.rb
CHANGED
data/lib/beagle/metrics.rb
CHANGED
data/lib/beagle/version.rb
CHANGED
@@ -0,0 +1,131 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Cucumber results</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body {
|
7
|
+
margin-left: 0 auto;
|
8
|
+
margin-right: 0 auto;
|
9
|
+
text-align:center;
|
10
|
+
width:100%;
|
11
|
+
}
|
12
|
+
table {
|
13
|
+
border-collapse:collapse;
|
14
|
+
border-spacing:0;
|
15
|
+
width: 100%;
|
16
|
+
}
|
17
|
+
table th,td {
|
18
|
+
padding:3px 5px;
|
19
|
+
text-align:left;
|
20
|
+
border: 1px solid #DDDDDD;
|
21
|
+
}
|
22
|
+
table th {
|
23
|
+
font-weight:bold;
|
24
|
+
}
|
25
|
+
table tfoot td {
|
26
|
+
font-weight:bold;
|
27
|
+
}
|
28
|
+
table thead tr {
|
29
|
+
background-color: #00FFFF;
|
30
|
+
}
|
31
|
+
.numeric {
|
32
|
+
text-align:right;
|
33
|
+
}
|
34
|
+
.invisible {
|
35
|
+
display: none;
|
36
|
+
}
|
37
|
+
.feature_file {
|
38
|
+
cursor: pointer;
|
39
|
+
}
|
40
|
+
#detail {
|
41
|
+
width:75%;
|
42
|
+
}
|
43
|
+
#summary {
|
44
|
+
width:18%;
|
45
|
+
}
|
46
|
+
#detail,#summary {
|
47
|
+
display:inline-block;
|
48
|
+
vertical-align:top;
|
49
|
+
padding:0 5px 0 5px;
|
50
|
+
}
|
51
|
+
</style>
|
52
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
|
53
|
+
<script type="text/javascript">
|
54
|
+
$(document).ready(function() {
|
55
|
+
|
56
|
+
$('.feature_file').live('click', function() {
|
57
|
+
$(this).next().toggleClass('invisible');
|
58
|
+
});
|
59
|
+
|
60
|
+
});
|
61
|
+
</script>
|
62
|
+
</head>
|
63
|
+
<body>
|
64
|
+
<div id="summary">
|
65
|
+
<table>
|
66
|
+
<thead>
|
67
|
+
<tr>
|
68
|
+
<th>Tag</th>
|
69
|
+
<th># Scenarios</th>
|
70
|
+
<th>Total Duration</th>
|
71
|
+
</tr>
|
72
|
+
</thead>
|
73
|
+
<tbody>
|
74
|
+
<% @by_tag.each do |tag, scenarios| %>
|
75
|
+
<tr>
|
76
|
+
<td><%= tag %></td>
|
77
|
+
<td class="numeric"><%= scenarios.inject(0){|s,t| s + t[:count]} %></td>
|
78
|
+
<td class="numeric"><%= scenarios.inject(0){|s,t| s + t[:time]}.round(2) %></td>
|
79
|
+
</tr>
|
80
|
+
<% end %>
|
81
|
+
</tbody>
|
82
|
+
</table>
|
83
|
+
</div>
|
84
|
+
<div id="detail">
|
85
|
+
<table>
|
86
|
+
<thead>
|
87
|
+
<tr>
|
88
|
+
<th>Feature</th>
|
89
|
+
<th># Scenarios</th>
|
90
|
+
<th>Tags</th>
|
91
|
+
<th>Total Duration</th>
|
92
|
+
</tr>
|
93
|
+
</thead>
|
94
|
+
<tbody>
|
95
|
+
<% @times.each do |entry| %>
|
96
|
+
<tr class="feature_file">
|
97
|
+
<td>...<%= entry[0] %></td>
|
98
|
+
<td class="numeric"><%= entry[1] %></td>
|
99
|
+
<td><%= entry[2].join(', ') %> </td>
|
100
|
+
<td class="numeric"><%= entry[3].round(2) %></td>
|
101
|
+
</tr>
|
102
|
+
<tr class="invisible">
|
103
|
+
<td colspan="4">
|
104
|
+
<table>
|
105
|
+
<tbody>
|
106
|
+
<% entry.last.each do |scenario| %>
|
107
|
+
<tr>
|
108
|
+
<td><%= scenario[:name] %></td>
|
109
|
+
<td class="numeric"><%= scenario[:count] %></td>
|
110
|
+
<td class="numeric"><%= scenario[:tags].join(', ') %></td>
|
111
|
+
<td class="numeric"><%= scenario[:time].round(2) %></td>
|
112
|
+
</tr>
|
113
|
+
<% end %>
|
114
|
+
</tbody>
|
115
|
+
</table>
|
116
|
+
</td>
|
117
|
+
</tr>
|
118
|
+
<% end %>
|
119
|
+
</tbody>
|
120
|
+
<tfoot>
|
121
|
+
<tr>
|
122
|
+
<td>Totals</td>
|
123
|
+
<td class="numeric"><%= @times.inject(0){|s,t| s + t[1]} %></td>
|
124
|
+
<td> </td>
|
125
|
+
<td class="numeric"><%= @times.inject(0){|s,t| s + t[3]}.round(2) %></td>
|
126
|
+
</tr>
|
127
|
+
</tfoot>
|
128
|
+
</table>
|
129
|
+
</div>
|
130
|
+
</body>
|
131
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Beagle::Examples do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@example = Beagle::Examples.new
|
7
|
+
example = mock('Example', :file_path => 'file', :full_description => 'description')
|
8
|
+
@example.add(example)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have a size" do
|
12
|
+
@example.size.should == 1
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob('lib/**/*.rb').each {|file| require file}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beagle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob Mitchell
|
@@ -15,9 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-08-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec-core
|
21
22
|
prerelease: false
|
22
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
@@ -30,10 +31,10 @@ dependencies:
|
|
30
31
|
- 0
|
31
32
|
- 0
|
32
33
|
version: 2.0.0
|
33
|
-
name: rspec-core
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
37
38
|
prerelease: false
|
38
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
@@ -46,10 +47,10 @@ dependencies:
|
|
46
47
|
- 8
|
47
48
|
- 7
|
48
49
|
version: 0.8.7
|
49
|
-
name: rake
|
50
50
|
type: :development
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
+
name: rspec
|
53
54
|
prerelease: false
|
54
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
@@ -62,7 +63,6 @@ dependencies:
|
|
62
63
|
- 0
|
63
64
|
- 0
|
64
65
|
version: 2.0.0
|
65
|
-
name: rspec-core
|
66
66
|
type: :development
|
67
67
|
version_requirements: *id003
|
68
68
|
description:
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
|
76
76
|
files:
|
77
|
+
- lib/beagle/cucumber/timed_formatter.rb
|
77
78
|
- lib/beagle/examples.rb
|
78
79
|
- lib/beagle/metrics.rb
|
79
80
|
- lib/beagle/timed_formatter.rb
|
@@ -81,7 +82,11 @@ files:
|
|
81
82
|
- lib/beagle.rb
|
82
83
|
- lib/js/highcharts.js
|
83
84
|
- lib/js/jquery-1.4.2.min.js
|
85
|
+
- lib/templates/cuke.rhtml
|
84
86
|
- lib/templates/index.rhtml
|
87
|
+
- spec/beagle/examples_spec.rb
|
88
|
+
- spec/beagle/metrics_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
85
90
|
- Rakefile
|
86
91
|
homepage: http://github.com/robmitch/beagle
|
87
92
|
licenses: []
|
@@ -112,9 +117,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
117
|
requirements: []
|
113
118
|
|
114
119
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.
|
120
|
+
rubygems_version: 1.8.8
|
116
121
|
signing_key:
|
117
122
|
specification_version: 3
|
118
123
|
summary: Provides execution times for your specs for analysis
|
119
124
|
test_files:
|
125
|
+
- spec/beagle/examples_spec.rb
|
126
|
+
- spec/beagle/metrics_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
120
128
|
- Rakefile
|