Created
July 6, 2009 15:02
-
-
Save joshuaclayton/141475 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { min-width: 950px; } | |
.cucumber { | |
background: #f4f4f4; | |
color: #666; | |
padding: 0 2% 1em; | |
width: 58%; | |
} | |
.cucumber .feature h2 { | |
font-size: 2.5em; | |
border-bottom: 3px solid #ccc; | |
padding: .5em 0; | |
} | |
.cucumber .feature p { | |
font-size: 2em; | |
line-height: 1.5em; | |
font-weight: bold; | |
color: #aaa; | |
font-style: italic; | |
} | |
.cucumber .feature p, .cucumber .scenario, .cucumber .background { | |
margin-left: 20px; | |
} | |
.cucumber .scenario, .cucumber .background { | |
background: #eee; | |
padding-bottom: 1px; | |
margin-bottom: 2em; | |
border: 1px solid #ccc; | |
} | |
.cucumber .scenario h3, .cucumber .background h3 { | |
color: #666; | |
padding: 10px; | |
font-size: 1.75em; | |
border-bottom: 1px solid #ccc; | |
background: #e8e8e8; | |
margin-bottom: 0; | |
} | |
.cucumber .scenario ol, .cucumber .background ol { | |
margin-top: 1em; | |
margin-left: 10px; | |
} | |
.cucumber .scenario li, .cucumber .background li { | |
list-style-type: none; | |
font-size: 1.375em; | |
line-height: 1em; | |
padding-left: 0; | |
margin-left: .5em; | |
} | |
.cucumber .feature li { color: #777; } | |
.cucumber .feature li span { font-weight: bold; } | |
.cucumber .feature li div { display: inline-block; } | |
.cucumber .feature li.passed span.swatch { background: green; } | |
.cucumber .feature li.undefined span.swatch { background: yellow; } | |
.cucumber .feature li.pending span.swatch { background: yellow; } | |
.cucumber .feature li.failed span.swatch { background: red; } | |
.cucumber .feature li.skipped span.swatch { background: cyan; } | |
.cucumber .feature li span.swatch { | |
display: inline-block; | |
position: relative; | |
top: .125em; | |
width: 1em; | |
height: 1em; | |
margin-right: .25em; | |
} | |
.cucumber pre { | |
border: 1px solid #aaa; | |
line-height: 1.375em; | |
font-size: 0.9em; | |
background: #222; | |
padding: 1em; | |
margin: .5em 3em .5em 1.75em; | |
} | |
.cucumber table { | |
border: 1px solid #ccc; | |
width: auto; | |
margin: 1em 0 0 1em; | |
} | |
.cucumber table tr:first-child td { | |
font-weight: bold; | |
border-bottom: 1px solid #ccc; | |
} | |
.toc { | |
position: fixed; | |
right: 0; | |
top: 0; | |
height: 100%; | |
overflow: auto; | |
width: 34%; | |
min-width: 300px; | |
background: #e9e9e9; | |
border-left: 5px solid #ccc; | |
padding: 0 2%; | |
} | |
.toc h2 { | |
padding: .25em 0; | |
font-size: 2.5em; | |
color: #666; | |
margin-bottom: 0; | |
} | |
.toc ul { margin: 0; } | |
.toc li.feature { margin: 0 0 1em 0;} | |
.toc li.feature:last-child { padding: 0 0 1em 0;} | |
.toc li.feature > a { | |
font-size: 1.5em; | |
font-weight: bold; | |
padding: .25em .5em; | |
display: inline-block; | |
} | |
.toc li.scenario { | |
padding: .25em 1.5em; | |
} | |
.toc li.scenario > a { | |
padding: .25em .5em; | |
line-height: 1.25em; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.outerHTML = function() { return $("<div/>").append(this.eq(0).clone()).html(); }; | |
$.extend(String.prototype, { | |
parameterize: function() { | |
return this.replace(/[^\w]+/g, '-').replace(/^\-|\-$/g, '').toLowerCase(); | |
} | |
}); | |
$(function(){ | |
// strip out escaped <span>'s | |
$(".cucumber .scenario li, .cucumber .background li").each(function(idx, li) { | |
var liHTML = $(li).html().replace(/<(\/?span)>/g, "<$1>"); | |
$(li).html(liHTML); | |
}); | |
$(".cucumber .scenario li, .cucumber .background li").each(function(idx, li) { | |
if(!$(li).find("span.swatch").length) { | |
$(li).prepend($("<span class='swatch'>")); | |
} | |
}); | |
(function() { | |
var $ulNavigation = $("<ul>").addClass("reset"); | |
$(".cucumber .feature").each(function(idx, feature) { | |
var $ulScenarios = $("<ul>"), | |
$feature = $(feature); | |
$feature.find(".scenario").each(function(idx2, scenario) { | |
var $scenario = $(scenario), | |
scenarioText = $scenario.find("> :header").text(); | |
$scenario.find("> :header").attr("id", scenarioText.parameterize()); | |
$("<li class='scenario'>") | |
.append($("<a>") | |
.attr("href", "#" + scenarioText.parameterize()) | |
.text(scenarioText)) | |
.appendTo($ulScenarios); | |
}); | |
var featureText = $feature.find("> :header").text(); | |
$feature.find("> :header").attr("id", featureText.parameterize()); | |
$("<li class='feature'>") | |
.append( | |
$("<a>") | |
.attr("href", "#" + featureText.parameterize()) | |
.text(featureText) | |
) | |
.append($ulScenarios) | |
.appendTo($ulNavigation); | |
}); | |
$("<div class='toc'>") | |
.append($("<h2>Feature Navigation</h2>")) | |
.append($ulNavigation) | |
.appendTo("body"); | |
})(); | |
}); | |
})(jQuery); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class File | |
def self.string_to_file(string, path) | |
directory = File.dirname(path) | |
FileUtils.mkdir_p directory unless File.directory?(directory) | |
File.open(path, 'w') { |f| f << string } | |
end | |
def self.path_to_string(path) | |
File.new(path).read | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :cucumber do | |
desc "Generates Cucumber results as an HTML file" | |
task :generate_html => :environment do | |
cucumber_output_path = File.join(RAILS_ROOT, "public", "cucumber.html") | |
system("cucumber -p html_output > #{cucumber_output_path}") | |
puts "Output Cucumber to public/cucumber.html" | |
doc = Hpricot.parse(File.path_to_string(cucumber_output_path)) | |
puts "Parsing cucumber.html" | |
doc.search("html head style:last") do |style| | |
style.after %{ | |
<link href="/stylesheets/reset.css" media="screen" rel="stylesheet" type="text/css" /> | |
<link href="/stylesheets/forms.css" media="screen" rel="stylesheet" type="text/css" /> | |
<link href="/stylesheets/extras.css" media="screen" rel="stylesheet" type="text/css" /> | |
<link href="/stylesheets/screen.css" media="screen" rel="stylesheet" type="text/css" /> | |
<link href="/stylesheets/admin.css" media="screen" rel="stylesheet" type="text/css" /> | |
<link href="/stylesheets/cucumber.css" media="screen" rel="stylesheet" type="text/css" /> | |
<script src="/javascripts/jquery-1.3.2.min.js" type="text/javascript"></script> | |
<script src="/javascripts/cucumber.js" type="text/javascript"></script> | |
} | |
end | |
puts "Saving cucumber.html" | |
File.string_to_file(doc.to_html, cucumber_output_path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment