start better reporter handling
This commit is contained in:
parent
12b48b1c6d
commit
943e754d59
3
Gemfile
3
Gemfile
|
@ -4,10 +4,13 @@ source "http://rubygems.org"
|
||||||
gemspec
|
gemspec
|
||||||
gem 'guard', :git => 'git://github.com/guard/guard.git'
|
gem 'guard', :git => 'git://github.com/guard/guard.git'
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
|
gem 'cucumber'
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'rake', '0.9.2'
|
gem 'rake', '0.9.2'
|
||||||
gem 'growl'
|
gem 'growl'
|
||||||
gem 'fakefs', :require => nil
|
gem 'fakefs', :require => nil
|
||||||
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
||||||
gem 'coffee-script'
|
gem 'coffee-script'
|
||||||
|
|
||||||
gem 'guard-rspec'
|
gem 'guard-rspec'
|
||||||
|
gem 'guard-cucumber'
|
||||||
|
|
|
@ -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 |
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -4,49 +4,44 @@ require 'jasmine-headless-webkit'
|
||||||
module Guard
|
module Guard
|
||||||
class JasmineHeadlessWebkit
|
class JasmineHeadlessWebkit
|
||||||
class Runner
|
class Runner
|
||||||
class << self
|
def self.run(paths = [], options = {})
|
||||||
def run(paths = [], options = {})
|
file = Tempfile.new('guard-jasmine-headless-webkit')
|
||||||
file = Tempfile.new('guard-jasmine-headless-webkit')
|
file.close
|
||||||
file.close
|
|
||||||
|
|
||||||
options.merge!(:reporters => [
|
options.merge!(:reporters => process_reporters, :colors => true, :files => paths)
|
||||||
[ 'Console' ],
|
|
||||||
[ 'File', file.path ]
|
|
||||||
], :colors => true, :files => paths)
|
|
||||||
|
|
||||||
Jasmine::Headless::Runner.run(options)
|
Jasmine::Headless::Runner.run(options)
|
||||||
|
|
||||||
notify(file.path)
|
notify(file.path)
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
else
|
||||||
|
raise Jasmine::Headless::InvalidReport
|
||||||
end
|
end
|
||||||
|
rescue Jasmine::Headless::InvalidReport => e
|
||||||
|
Notifier.notify('Spec runner interrupted!', :title => 'Jasmine results', :image => :failed)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def notify(file)
|
private
|
||||||
if (report = Jasmine::Headless::Report.load(file)).valid?
|
def self.message(total, fails, secs, any_console)
|
||||||
Notifier.notify(message(report.total, report.failed, report.time, report.has_used_console?), :title => 'Jasmine results', :image => image(report.has_used_console?, report.failed))
|
total_word = (total.to_i == 1) ? "test" : "tests"
|
||||||
report.failed_files
|
|
||||||
|
"#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.image(any_console, fails)
|
||||||
|
if any_console
|
||||||
|
:pending
|
||||||
|
else
|
||||||
|
if fails.to_i == 0
|
||||||
|
:success
|
||||||
else
|
else
|
||||||
raise Jasmine::Headless::InvalidReport
|
:failed
|
||||||
end
|
|
||||||
rescue Jasmine::Headless::InvalidReport => e
|
|
||||||
Notifier.notify('Spec runner interrupted!', :title => 'Jasmine results', :image => :failed)
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def 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)
|
|
||||||
if any_console
|
|
||||||
:pending
|
|
||||||
else
|
|
||||||
if fails.to_i == 0
|
|
||||||
:success
|
|
||||||
else
|
|
||||||
:failed
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,23 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Guard::JasmineHeadlessWebkit::Runner do
|
describe Guard::JasmineHeadlessWebkit::Runner do
|
||||||
describe '.run' do
|
describe '.run' do
|
||||||
|
let(:reporter) { 'reporter' }
|
||||||
|
|
||||||
|
before do
|
||||||
|
described_class.stubs(:process_reporters).returns([ reporter ])
|
||||||
|
end
|
||||||
|
|
||||||
it 'should pass along options' do
|
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)
|
Guard::JasmineHeadlessWebkit::Runner.run([], :full_run => false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.process_reporters' do
|
||||||
|
subject {
|
||||||
|
end
|
||||||
|
|
||||||
describe '.notify' do
|
describe '.notify' do
|
||||||
include FakeFS::SpecHelpers
|
include FakeFS::SpecHelpers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue