raise exceptions on rake task failures, hopefully addresses #26
This commit is contained in:
parent
7316f77367
commit
99c939e6d0
@ -5,6 +5,9 @@ module Jasmine
|
||||
"The jasmine-headless-webkit specrunner (jasmine-webkit-specrunner) could not be found! Try reinstalling the gem."
|
||||
end
|
||||
end
|
||||
|
||||
class TestFailure < StandardError; end
|
||||
class ConsoleLogUsage < StandardError ; end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -35,13 +35,8 @@ module Jasmine
|
||||
yield self if block_given?
|
||||
|
||||
desc 'Run Jasmine specs headlessly'
|
||||
task name do
|
||||
Jasmine::Headless::Runner.run(
|
||||
:colors => colors,
|
||||
:remove_html_file => !@keep_on_error,
|
||||
:jasmine_config => @jasmine_config
|
||||
)
|
||||
end
|
||||
task(name) { run_rake_task }
|
||||
|
||||
create_rails_compliant_task if defined?(Rails)
|
||||
end
|
||||
|
||||
@ -56,6 +51,19 @@ module Jasmine
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run_rake_task
|
||||
case Jasmine::Headless::Runner.run(
|
||||
:colors => colors,
|
||||
:remove_html_file => !@keep_on_error,
|
||||
:jasmine_config => @jasmine_config
|
||||
)
|
||||
when 1
|
||||
raise Jasmine::Headless::TestFailure
|
||||
when 2
|
||||
raise Jasmine::Headless::ConsoleLogUsage
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,16 +4,16 @@ require 'jasmine/headless/task'
|
||||
require 'mocha'
|
||||
|
||||
describe Jasmine::Headless::Task do
|
||||
before do
|
||||
Jasmine::Headless::Task.any_instance.stubs(:desc)
|
||||
Jasmine::Headless::Task.any_instance.stubs(:task)
|
||||
end
|
||||
|
||||
after do
|
||||
Object.send(:remove_const, :Rails) if defined?(Rails)
|
||||
end
|
||||
|
||||
describe 'define task' do
|
||||
before do
|
||||
Jasmine::Headless::Task.any_instance.stubs(:desc)
|
||||
Jasmine::Headless::Task.any_instance.stubs(:task)
|
||||
end
|
||||
|
||||
context 'without Rails' do
|
||||
it 'should not explode when Rails is undefined' do
|
||||
Jasmine::Headless::Task.new('jasmine:headless')
|
||||
@ -34,5 +34,43 @@ describe Jasmine::Headless::Task do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'jasmine:headless integration test' do
|
||||
context 'with successful test' do
|
||||
let(:test) do
|
||||
described_class.new do |t|
|
||||
t.jasmine_config = "spec/jasmine/success/success.yml"
|
||||
end
|
||||
end
|
||||
|
||||
it 'should do nothing on success' do
|
||||
expect { test.send(:run_rake_task) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'with failing test' do
|
||||
let(:test) do
|
||||
described_class.new do |t|
|
||||
t.jasmine_config = "spec/jasmine/failure/failure.yml"
|
||||
end
|
||||
end
|
||||
|
||||
it 'should raise an exception on failure' do
|
||||
expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::TestFailure)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with console.log using test' do
|
||||
let(:test) do
|
||||
described_class.new do |t|
|
||||
t.jasmine_config = "spec/jasmine/console_log/console_log.yml"
|
||||
end
|
||||
end
|
||||
|
||||
it 'should raise an exception on console.log usage' do
|
||||
expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::ConsoleLogUsage)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user