start better reporter handling

This commit is contained in:
John Bintz 2012-01-10 17:14:46 -05:00
parent 12b48b1c6d
commit 943e754d59
10 changed files with 88 additions and 38 deletions

View File

@ -4,10 +4,13 @@ source "http://rubygems.org"
gemspec
gem 'guard', :git => 'git://github.com/guard/guard.git'
gem 'rspec'
gem 'cucumber'
gem 'mocha'
gem 'rake', '0.9.2'
gem 'growl'
gem 'fakefs', :require => nil
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
gem 'coffee-script'
gem 'guard-rspec'
gem 'guard-cucumber'

11
features/runner.feature Normal file
View File

@ -0,0 +1,11 @@
Feature: Runner
Scenario: Don't specify a reporter
Given I am going to call a JHW runner
And I am going to get a notification file
When I don't specify a reporter
And I run the runner
Then I should get the following reporters:
| name | file |
| Console | |
| File | notify-file |

View File

@ -0,0 +1,3 @@
Given /^I am going to call a JHW runner$/ do
pending # express the regexp above with the code you wish you had
end

View File

@ -0,0 +1,3 @@
Given /^I am going to get a notification file$/ do
pending # express the regexp above with the code you wish you had
end

View File

@ -0,0 +1,5 @@
Then /^I should get the following reporters:$/ do |table|
# table is a Cucumber::Ast::Table
pending # express the regexp above with the code you wish you had
end

View File

@ -0,0 +1,3 @@
When /^I don't specify a reporter$/ do
pending # express the regexp above with the code you wish you had
end

17
features/support/env.rb Normal file
View File

@ -0,0 +1,17 @@
require 'rspec'
require 'mocha'
World(Mocha::Standalone)
Before do
mocha_setup
end
After do
begin
mocha_verify
ensure
mocha_teardown
end
end

View File

@ -4,22 +4,18 @@ require 'jasmine-headless-webkit'
module Guard
class JasmineHeadlessWebkit
class Runner
class << self
def run(paths = [], options = {})
def self.run(paths = [], options = {})
file = Tempfile.new('guard-jasmine-headless-webkit')
file.close
options.merge!(:reporters => [
[ 'Console' ],
[ 'File', file.path ]
], :colors => true, :files => paths)
options.merge!(:reporters => process_reporters, :colors => true, :files => paths)
Jasmine::Headless::Runner.run(options)
notify(file.path)
end
def notify(file)
def self.notify(file)
if (report = Jasmine::Headless::Report.load(file)).valid?
Notifier.notify(message(report.total, report.failed, report.time, report.has_used_console?), :title => 'Jasmine results', :image => image(report.has_used_console?, report.failed))
report.failed_files
@ -32,13 +28,13 @@ module Guard
end
private
def message(total, fails, secs, any_console)
def self.message(total, fails, secs, any_console)
total_word = (total.to_i == 1) ? "test" : "tests"
"#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
end
def image(any_console, fails)
def self.image(any_console, fails)
if any_console
:pending
else
@ -51,5 +47,4 @@ module Guard
end
end
end
end
end

View File

@ -2,13 +2,23 @@ require 'spec_helper'
describe Guard::JasmineHeadlessWebkit::Runner do
describe '.run' do
let(:reporter) { 'reporter' }
before do
described_class.stubs(:process_reporters).returns([ reporter ])
end
it 'should pass along options' do
Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
Jasmine::Headless::Runner.expects(:run).with(all_of(has_key(:full_run), has_entry(:reporters => [ reporter ])))
Guard::JasmineHeadlessWebkit::Runner.run([], :full_run => false)
end
end
describe '.process_reporters' do
subject {
end
describe '.notify' do
include FakeFS::SpecHelpers