Permalink
Browse files

Generate an index.html file in the report dir. Release 0.4.3.

  • Loading branch information...
1 parent b5e3382 commit 27b2409a5ccfef0f344fb6fdbb4aa8390db2192f @aslakhellesoy aslakhellesoy committed Jun 25, 2011
Showing with 62 additions and 12 deletions.
  1. +5 −5 Gemfile.lock
  2. +4 −0 History.md
  3. +1 −0 README.md
  4. +1 −1 aruba.gemspec
  5. +30 −5 lib/aruba/reporting.rb
  6. +20 −0 templates/index.erb
  7. +1 −1 templates/main.erb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- aruba (0.4.2)
+ aruba (0.4.3)
bcat (>= 0.6.1)
childprocess (>= 0.1.9)
cucumber (>= 0.10.7)
@@ -16,17 +16,17 @@ GEM
builder (3.0.0)
childprocess (0.1.9)
ffi (~> 1.0.6)
- cucumber (0.10.7)
+ cucumber (1.0.0)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
- gherkin (~> 2.4.0)
+ gherkin (~> 2.4.1)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
ffi (1.0.9)
- gherkin (2.4.0)
+ gherkin (2.4.1)
json (>= 1.4.6)
- json (1.5.2)
+ json (1.5.3)
rack (1.3.0)
rdiscount (1.6.8)
rspec (2.6.0)
View
@@ -1,3 +1,7 @@
+## [v0.4.3](https://github.com/cucumber/aruba/compare/v0.4.2...v0.4.3)
+
+* Aruba reporting now creates an index file for reports, linking them all together. (Aslak Hellesøy)
+
## [v0.4.2](https://github.com/cucumber/aruba/compare/v0.4.1...v0.4.2)
* Appending to a file creates the parent directory if it doesn't exist. (Aslak Hellesøy)
View
@@ -96,6 +96,7 @@ Aruba can generate a HTML page for each scenario that contains:
* The output from those commands (in colour if the output uses ANSI escapes)
* The files that were created (syntax highlighted in in colour)
+In addition to this, it creates an `index.html` file with links to all individual report files.
Reporting is off by default, but you can enable it by defining the `ARUBA_REPORT_DIR` environment variable, giving it the value
where reports should be written:
View
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = 'aruba'
- s.version = '0.4.2'
+ s.version = '0.4.3'
s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak"]
s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
s.summary = "aruba-#{s.version}"
View
@@ -10,6 +10,14 @@
module Aruba
module Reporting
+ class << self
+ def reports
+ @reports ||= Hash.new do |hash, feature|
+ hash[feature] = []
+ end
+ end
+ end
+
def pygmentize(file)
pygmentize = Process.new(%{pygmentize -f html -O encoding=utf-8 "#{file}"}, 3, 0.5)
pygmentize.run! do |p|
@@ -75,23 +83,40 @@ def template(path)
def depth
File.dirname(@scenario.feature.file).split('/').length
end
+
+ def index
+ erb = ERB.new(template('index.erb'), nil, '-')
+ erb.result(binding)
+ end
+
+ def index_title
+ "Examples"
+ end
end
end
World(Aruba::Reporting)
- Before do |scenario|
+ After do |scenario|
@scenario = scenario
- end
-
- After do
- report_file = File.join(ENV['ARUBA_REPORT_DIR'], "#{@scenario.feature.file}:#{@scenario.line}.html")
+ html_file = "#{scenario.feature.file}:#{scenario.line}.html"
+ report_file = File.join(ENV['ARUBA_REPORT_DIR'], html_file)
_mkdir(File.dirname(report_file))
File.open(report_file, 'w') do |io|
io.write(report)
end
+ Aruba::Reporting.reports[scenario.feature] << [scenario, html_file]
+
FileUtils.cp_r(File.join(ENV['ARUBA_REPORT_TEMPLATES'], '.'), ENV['ARUBA_REPORT_DIR'])
Dir["#{ENV['ARUBA_REPORT_DIR']}/**/*.erb"].each{|f| FileUtils.rm(f)}
end
+
+ at_exit do
+ index_file = File.join(ENV['ARUBA_REPORT_DIR'], "index.html")
+ extend(Aruba::Reporting)
+ File.open(index_file, 'w') do |io|
+ io.write(index)
+ end
+ end
end
View
@@ -0,0 +1,20 @@
+<!doctype html>
+
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
+ <title><%= index_title %></title>
+</head>
+<body>
+
+<h2><%= index_title %></h2>
+<% Aruba::Reporting.reports.keys.sort{|f1, f2| f1.title <=> f2.title}.each do |feature| -%>
+ <h3><%= feature.title %></h3>
+ <ul>
+ <% Aruba::Reporting.reports[feature].each do |scenario, report_path| %>
+ <li><a href="<%= report_path%>"><%= scenario.title %></a></li>
+ <% end -%>
+ </ul>
+<% end -%>
+
+</body>
View
@@ -26,7 +26,7 @@
<h3>Output</h3>
<pre class="console">
<% commands.each do |cmd| -%>
- <%= cmd %>
+$ <%= cmd %>
<% end -%>
<%= output %>
</pre>

0 comments on commit 27b2409

Please sign in to comment.