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'
|
||||||
|
11
features/runner.feature
Normal file
11
features/runner.feature
Normal 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 |
|
||||||
|
|
@ -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
|
5
features/step_definitions/then/i_should_get_reporters.rb
Normal file
5
features/step_definitions/then/i_should_get_reporters.rb
Normal 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
|
||||||
|
|
@ -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
features/step_definitions/when/i_run_the_runner.rb
Normal file
0
features/step_definitions/when/i_run_the_runner.rb
Normal file
17
features/support/env.rb
Normal file
17
features/support/env.rb
Normal 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
|
||||||
|
|
@ -4,22 +4,18 @@ 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
|
end
|
||||||
|
|
||||||
def notify(file)
|
def self.notify(file)
|
||||||
if (report = Jasmine::Headless::Report.load(file)).valid?
|
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))
|
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
|
report.failed_files
|
||||||
@ -32,13 +28,13 @@ module Guard
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
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_word = (total.to_i == 1) ? "test" : "tests"
|
||||||
|
|
||||||
"#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
|
"#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
|
||||||
end
|
end
|
||||||
|
|
||||||
def image(any_console, fails)
|
def self.image(any_console, fails)
|
||||||
if any_console
|
if any_console
|
||||||
:pending
|
:pending
|
||||||
else
|
else
|
||||||
@ -51,5 +47,4 @@ module Guard
|
|||||||
end
|
end
|
||||||
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
Block a user