Skip to content

Commit

Permalink
Support running multiple specs at a time, in-browser. Closes NUBIC#5.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsutphin committed Nov 30, 2009
1 parent ed3a3f1 commit f0224ee
Show file tree
Hide file tree
Showing 19 changed files with 569 additions and 138 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rdoc
pkg
spec/tmp
*.gemspec
.sass-cache
3 changes: 3 additions & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
0.2.0
=====

* Running multiple specs in-browser using iframes (issue #5)
* Use a single stylesheet for single specs, multirunner, and index page
* Allow override of the default runner stylesheet using a file at the root of spec_path; either shenandoah.sass or shenandoah.css
* Stop publishing the gem to rubyforge (but continue deploying rdoc there)
* Basic full-execution test coverage with cucumber features

Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ begin
gem.add_runtime_dependency('haml', '>= 2.0.9')
gem.add_runtime_dependency('rake')
gem.add_runtime_dependency('rails', '>= 2.1.0')
gem.add_runtime_dependency('compass')

# Have to use rspec 1.2.4 for buildr compat
gem.add_development_dependency('rspec', '= 1.2.4')
Expand Down
2 changes: 1 addition & 1 deletion features/example_projects/base/spec/cells.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<title>cells.js | JavaScript Testing Results</title>
<link rel="stylesheet" href="/screw.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="/shenandoah.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="/shenandoah/browser-runner.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion features/example_projects/base/spec/life.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<title>life.js | JavaScript Testing Results</title>
<link rel="stylesheet" href="/screw.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="/shenandoah.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="/shenandoah/browser-runner.js"></script>
</head>

Expand Down
90 changes: 0 additions & 90 deletions lib/shenandoah/css/screw.css

This file was deleted.

138 changes: 138 additions & 0 deletions lib/shenandoah/css/shenandoah.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
@import compass/reset

!running = #CC6600
!passed = #5A753D
!failed = #993300
!border_color = #6E6E6E
!background_color = #EDEBD5

body
padding: 0.5em
font-family: Helvetica, sans-serif
background= !background_color

li
list-style-type: none

.focused
background-color: #F4F2E4
*
opacity: 1.0

h3.status
font-style: italic
padding-bottom: 1em

h1, h2, p
opacity: 0.4

.describes
padding-left: 0

h1
font-size: 1.1em
color: #877C21
line-height: 1.8em
margin: 0pt 0pt 0.6em
border-bottom: 1px solid transparent
font-weight: bold

&:hover
cursor: pointer
color: #000
background-color: #F4F2E4
border-bottom: 1px solid #9A8E51

.describe
margin-left: 0.6em
padding-left: 0.6em
margin-bottom: 2px
margin-right: 2px
border= 1px "dotted" !border_color

.its .it
list-style-type: lower-roman
list-style-position: outside
margin-left: 2.0em

h2
font-weight: normal
font-style: normal
padding-left: 0.5em
font-size: 1.0em
color: #877C21
line-height: 1.8em
margin: 0 0 0.5em
border-bottom: 1px solid transparent

&.enqueued h2
background-color= !running
color: white !important

&.passed h2
background-color= !passed
color: white !important

&.failed
h2
background-color= !failed
color: white !important

p
margin-left: 1em
color= !failed

h2:hover
cursor: pointer
color: #000 !important
border-bottom: 1px solid #9A8E51

// Index styles
body#index
padding: 3em
ul li
margin-left: 1.2em
list-style-type: disc
line-height: 1.2em
h2
font-size: 1.2em
margin: 0.5em 0
#controls
margin-top: 1em
#select-all
margin-left: 1.2em

// Multirunner styles
#frames
clear: both

#frames iframe
width: 94%
height: 90%
display: none
border= 2px "solid" !border_color
margin: 1em 2%
clear: both
&.active
display: block

#specs li
display: block
padding: 4px
margin: 2px
background-color= !background_color - #333
float: left
border= 2px "solid" !background_color
cursor: pointer
&.active
border-color= !border_color
&.passed
background-color= !passed
color: #ddd
&.failed
background-color= !failed
color: #ddd
span.name
color: #fff
18 changes: 18 additions & 0 deletions lib/shenandoah/javascript/browser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function ($) {
$(document).ready(function () {
var checkboxes_selector = "form input";

$('#select-all input').click(function () {
if ($(this).is(':checked')) {
$(checkboxes_selector).attr('checked', true);
} else {
$(checkboxes_selector).attr('checked', false);
}
});

$(checkboxes_selector).click(function () {
$('#select-all input').attr('checked',
$(checkboxes_selector).filter(':checked').size() == $(checkboxes_selector).size());
});
});
}(jQuery));
32 changes: 32 additions & 0 deletions lib/shenandoah/javascript/browser/multirunner-single.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if (!window.shenandoah) { shenandoah = { }; }

(function ($) {
shenandoah.MultirunnerFrame = function () {
// Finds the IFRAME which contains this window in the parent DOM
var containingFrame = $.grep(window.parent.jQuery('iframe'), function (iframe, idx) {
return iframe.contentWindow === window;
})[0];

function parentTrigger(name, data) {
if (containingFrame) {
window.parent.jQuery(containingFrame).trigger(name, data);
}
}

this.register = function () {
$(Screw).bind('after', function () {
parentTrigger('complete', {
passed_count: $('.passed').length,
failed_count: $('.failed').length,
total_count: $('.passed').length + $('.failed').length
});
});
};
};


$(document).ready(function () {
new shenandoah.MultirunnerFrame().register();
});

}(jQuery));
Loading

0 comments on commit f0224ee

Please sign in to comment.