Skip to content

Commit

Permalink
Successively print out spec results
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Oct 21, 2010
1 parent 9b9dfb5 commit 0384bd5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions lib/evergreen/resources/evergreen.js
Expand Up @@ -2,6 +2,8 @@ if(!this.JSON){this.JSON={};}

var Evergreen = {};

Evergreen.dots = ""

Evergreen.ReflectiveReporter = function() {
this.reportRunnerStarting = function(runner) {
Evergreen.results = [];
Expand All @@ -15,6 +17,7 @@ Evergreen.ReflectiveReporter = function() {
message: item.message,
trace: item.trace
});
Evergreen.dots += (results.failedCount === 0) ? "." : "F";
};
this.reportRunnerResults = function(runner) {
Evergreen.done = true;
Expand Down
21 changes: 15 additions & 6 deletions lib/evergreen/runner.rb
Expand Up @@ -9,10 +9,6 @@ def passed?
@row['passed']
end

def dot
if passed? then '.' else 'F' end
end

def failure_message
unless passed?
msg = []
Expand Down Expand Up @@ -50,7 +46,20 @@ def run
def examples
@results ||= begin
session.visit(spec.url)
session.wait_until(180) { session.evaluate_script('Evergreen.done') }

previous_results = ""

session.wait_until(180) do
dots = session.evaluate_script('Evergreen.dots')
io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')
io.flush
previous_results = dots
session.evaluate_script('Evergreen.done')
end

dots = session.evaluate_script('Evergreen.dots')
io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')

JSON.parse(session.evaluate_script('Evergreen.getResults()')).map do |row|
Example.new(row)
end
Expand All @@ -66,7 +75,7 @@ def passed?
end

def dots
examples.map { |example| example.dot }.join
examples; ""
end

def failure_messages
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -17,11 +17,12 @@ module EvergreenMatchers
class PassSpec # :nodoc:
def matches?(actual)
@actual = actual
@actual.passed?
@runner = Evergreen::Runner.new(actual.suite, StringIO.new).spec_runner(@actual)
@runner.passed?
end

def failure_message
"expected #{@actual.name} to pass, but it failed with:\n\n#{@actual.failure_messages}"
"expected #{@actual.name} to pass, but it failed with:\n\n#{@runner.failure_messages}"
end

def negative_failure_message
Expand Down

0 comments on commit 0384bd5

Please sign in to comment.