better reporter support
This commit is contained in:
parent
943e754d59
commit
b3e88261f0
14
Gemfile
14
Gemfile
@ -2,15 +2,19 @@ source "http://rubygems.org"
|
|||||||
|
|
||||||
# Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
|
# Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
gem 'guard', :git => 'git://github.com/guard/guard.git'
|
gem 'rake', '0.9.2'
|
||||||
|
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'cucumber'
|
gem 'cucumber'
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'rake', '0.9.2'
|
|
||||||
gem 'growl'
|
|
||||||
gem 'fakefs', :require => nil
|
gem 'fakefs', :require => nil
|
||||||
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
|
||||||
gem 'coffee-script'
|
|
||||||
|
|
||||||
|
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
||||||
|
|
||||||
|
gem 'guard', :git => 'git://github.com/guard/guard.git'
|
||||||
gem 'guard-rspec'
|
gem 'guard-rspec'
|
||||||
gem 'guard-cucumber'
|
gem 'guard-cucumber'
|
||||||
|
|
||||||
|
gem 'growl'
|
||||||
|
gem 'rb-fsevent'
|
||||||
|
|
||||||
|
16
Guardfile
16
Guardfile
@ -5,13 +5,11 @@ guard 'rspec', :cli => '-c', :version => 2 do
|
|||||||
watch(%r{^spec/.+_spec\.rb})
|
watch(%r{^spec/.+_spec\.rb})
|
||||||
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||||
watch('spec/spec_helper.rb') { "spec" }
|
watch('spec/spec_helper.rb') { "spec" }
|
||||||
|
|
||||||
# Rails example
|
|
||||||
watch('spec/spec_helper.rb') { "spec" }
|
|
||||||
watch('config/routes.rb') { "spec/routing" }
|
|
||||||
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
||||||
watch(%r{^spec/.+_spec\.rb})
|
|
||||||
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
||||||
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
||||||
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guard 'cucumber', :cli => '-f pretty' do
|
||||||
|
watch(%r{^features/.+\.feature$})
|
||||||
|
watch(%r{^features/support/.+$}) { 'features' }
|
||||||
|
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
||||||
|
end
|
||||||
|
|
||||||
|
5
Rakefile
5
Rakefile
@ -13,11 +13,11 @@ require 'rspec/core/rake_task'
|
|||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
|
PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3}
|
||||||
|
|
||||||
def rvm_bundle(command = '')
|
def rvm_bundle(command = '')
|
||||||
Bundler.with_clean_env do
|
Bundler.with_clean_env do
|
||||||
system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} do bundle #{command}'}.tap { |o| p o }
|
system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} do bundle #{command}'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ namespace :spec do
|
|||||||
task :platforms do
|
task :platforms do
|
||||||
rvm_bundle "update"
|
rvm_bundle "update"
|
||||||
rvm_bundle "exec rspec spec"
|
rvm_bundle "exec rspec spec"
|
||||||
|
rvm_bundle "exec cucumber"
|
||||||
raise SpecError.new if $?.exitstatus != 0
|
raise SpecError.new if $?.exitstatus != 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,33 @@
|
|||||||
Feature: Runner
|
Feature: Runner
|
||||||
Scenario: Don't specify a reporter
|
Scenario: Don't specify a reporter
|
||||||
Given I am going to call a JHW runner
|
Given I am going to call a JHW runner with the following reporters:
|
||||||
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 |
|
| name | file |
|
||||||
| Console | |
|
| Console | |
|
||||||
| File | notify-file |
|
| File | notify-file |
|
||||||
|
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 reporters
|
||||||
|
|
||||||
|
Scenario: Specify another console reporter
|
||||||
|
Given I am going to call a JHW runner with the following reporters:
|
||||||
|
| name | file |
|
||||||
|
| Verbose | |
|
||||||
|
| File | notify-file |
|
||||||
|
And I am going to get a notification file
|
||||||
|
When I specify the reporter "Verbose"
|
||||||
|
And I run the runner
|
||||||
|
Then I should get the reporters
|
||||||
|
And the reporter string should not have changed
|
||||||
|
|
||||||
|
Scenario: Specify two reporters
|
||||||
|
Given I am going to call a JHW runner with the following reporters:
|
||||||
|
| name | file |
|
||||||
|
| Verbose | |
|
||||||
|
| Tap | tap-file |
|
||||||
|
| File | notify-file |
|
||||||
|
And I am going to get a notification file
|
||||||
|
When I specify the reporter "Verbose Tap:tap-file"
|
||||||
|
And I run the runner
|
||||||
|
Then I should get the reporters
|
||||||
|
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
Given /^I am going to call a JHW runner$/ do
|
Given /^I am going to call a JHW runner with the following reporters:$/ do |table|
|
||||||
pending # express the regexp above with the code you wish you had
|
reporters = []
|
||||||
|
|
||||||
|
table.rows.each do | name, file |
|
||||||
|
reporters << [ name ]
|
||||||
|
|
||||||
|
reporters.last << file if !file.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
Jasmine::Headless::Runner.expects(:run).with(has_entry(:reporters => reporters))
|
||||||
|
Guard::JasmineHeadlessWebkit::Runner.expects(:notify)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
Given /^I am going to get a notification file$/ do
|
Given /^I am going to get a notification file$/ do
|
||||||
pending # express the regexp above with the code you wish you had
|
Guard::JasmineHeadlessWebkit::Runner.stubs(:notify_report_file).returns(@report_file)
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
Then /^I should get the following reporters:$/ do |table|
|
Then /^I should get the reporters$/ do
|
||||||
# table is a Cucumber::Ast::Table
|
|
||||||
pending # express the regexp above with the code you wish you had
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the reporter string should not have changed$/ do
|
||||||
|
@options[:reporters].should == @requested_reporter
|
||||||
|
end
|
@ -1,3 +1,3 @@
|
|||||||
When /^I don't specify a reporter$/ do
|
When /^I don't specify a reporter$/ do
|
||||||
pending # express the regexp above with the code you wish you had
|
@options = {}
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
When /^I run the runner$/ do
|
||||||
|
Guard::JasmineHeadlessWebkit::Runner.run(@paths, @options)
|
||||||
|
end
|
6
features/step_definitions/when/i_specify_reporter.rb
Normal file
6
features/step_definitions/when/i_specify_reporter.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
When /^I specify the reporter "([^"]*)"$/ do |reporter|
|
||||||
|
@requested_reporter = reporter
|
||||||
|
|
||||||
|
@options = { :reporters => reporter }
|
||||||
|
end
|
||||||
|
|
@ -1,10 +1,21 @@
|
|||||||
require 'rspec'
|
require 'rspec'
|
||||||
require 'mocha'
|
require 'mocha'
|
||||||
|
require 'fakefs/safe'
|
||||||
|
|
||||||
World(Mocha::Standalone)
|
require 'jasmine-headless-webkit'
|
||||||
|
require 'guard/jasmine-headless-webkit'
|
||||||
|
|
||||||
|
require 'coffee-script'
|
||||||
|
|
||||||
|
World(Mocha::API)
|
||||||
|
|
||||||
Before do
|
Before do
|
||||||
mocha_setup
|
mocha_setup
|
||||||
|
|
||||||
|
FakeFS.activate!
|
||||||
|
|
||||||
|
@report_file = 'notify-file'
|
||||||
|
@paths = []
|
||||||
end
|
end
|
||||||
|
|
||||||
After do
|
After do
|
||||||
@ -13,5 +24,7 @@ After do
|
|||||||
ensure
|
ensure
|
||||||
mocha_teardown
|
mocha_teardown
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FakeFS.deactivate!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,14 +5,34 @@ module Guard
|
|||||||
class JasmineHeadlessWebkit
|
class JasmineHeadlessWebkit
|
||||||
class Runner
|
class Runner
|
||||||
def self.run(paths = [], options = {})
|
def self.run(paths = [], options = {})
|
||||||
file = Tempfile.new('guard-jasmine-headless-webkit')
|
report_file = notify_report_file
|
||||||
file.close
|
|
||||||
|
|
||||||
options.merge!(:reporters => process_reporters, :colors => true, :files => paths)
|
options = options.merge(:reporters => process_reporters(options[:reporters], report_file), :colors => true, :files => paths)
|
||||||
|
|
||||||
Jasmine::Headless::Runner.run(options)
|
Jasmine::Headless::Runner.run(options)
|
||||||
|
|
||||||
notify(file.path)
|
notify(report_file)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.notify_report_file
|
||||||
|
file = Tempfile.new('guard-jasmine-headless-webkit')
|
||||||
|
file.close
|
||||||
|
file.path
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.process_reporters(reporters, report_file)
|
||||||
|
reporters ||= 'Console'
|
||||||
|
|
||||||
|
out = []
|
||||||
|
|
||||||
|
reporters.split(' ').each do |reporter|
|
||||||
|
name, file = reporter.split(':', 2)
|
||||||
|
|
||||||
|
out << [ name ]
|
||||||
|
out.last << file if file && !file.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
out + [ [ 'File', report_file ] ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.notify(file)
|
def self.notify(file)
|
||||||
|
@ -16,7 +16,27 @@ describe Guard::JasmineHeadlessWebkit::Runner do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '.process_reporters' do
|
describe '.process_reporters' do
|
||||||
subject {
|
subject { described_class.process_reporters(reporters, report_file) }
|
||||||
|
|
||||||
|
let(:report_file) { 'report file' }
|
||||||
|
|
||||||
|
context 'none provided' do
|
||||||
|
let(:reporters) { nil }
|
||||||
|
|
||||||
|
it { should == [ [ 'Console' ], [ 'File', report_file ] ] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'one provided' do
|
||||||
|
let(:reporters) { 'One' }
|
||||||
|
|
||||||
|
it { should == [ [ 'One' ], [ 'File', report_file ] ] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'two provided' do
|
||||||
|
let(:reporters) { 'One Two:file.txt' }
|
||||||
|
|
||||||
|
it { should == [ [ 'One' ], [ 'Two', 'file.txt' ], [ 'File', report_file ] ] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.notify' do
|
describe '.notify' do
|
||||||
|
Loading…
Reference in New Issue
Block a user