2011-04-14 00:21:23 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "jasmine-headless-webkit" do
|
2011-05-29 16:30:19 +00:00
|
|
|
let(:report) { 'spec/report.txt' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
FileUtils.rm_f report
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_f report
|
|
|
|
end
|
|
|
|
|
2011-04-14 00:21:23 +00:00
|
|
|
describe 'success' do
|
|
|
|
it "should succeed with error code 0" do
|
2011-05-29 16:30:19 +00:00
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report #{report}}
|
2011-04-14 00:21:23 +00:00
|
|
|
$?.exitstatus.should == 0
|
2011-05-29 16:30:19 +00:00
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(1, 0, false)
|
2011-04-14 00:21:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-31 13:37:29 +00:00
|
|
|
|
|
|
|
describe 'success but with js error' do
|
|
|
|
it "should succeed with error code 0" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
|
|
|
|
$?.exitstatus.should == 1
|
|
|
|
|
2011-06-29 14:38:15 +00:00
|
|
|
# returns are unpredictable due to changes in jasmine! >.<
|
|
|
|
# all we can do is ensure that we've actually failed
|
|
|
|
#
|
|
|
|
# report.should be_a_report_containing(0, 0, false)
|
2011-05-31 13:37:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-14 00:21:23 +00:00
|
|
|
describe 'failure' do
|
|
|
|
it "should fail with an error code of 1" do
|
2011-05-29 16:30:19 +00:00
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}}
|
2011-04-14 00:21:23 +00:00
|
|
|
$?.exitstatus.should == 1
|
2011-05-29 16:30:19 +00:00
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(1, 1, false)
|
2011-04-14 00:21:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with console.log' do
|
|
|
|
it "should succeed, but has a console.log so an error code of 2" do
|
2011-05-29 16:30:19 +00:00
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml --report #{report}}
|
2011-04-14 00:21:23 +00:00
|
|
|
$?.exitstatus.should == 2
|
2011-05-29 16:30:19 +00:00
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(1, 0, true)
|
2011-04-14 00:21:23 +00:00
|
|
|
end
|
|
|
|
end
|
2011-06-10 15:02:26 +00:00
|
|
|
|
2011-06-10 21:14:50 +00:00
|
|
|
describe 'with coffeescript error' do
|
|
|
|
it "should fail" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml --report #{report}}
|
|
|
|
$?.exitstatus.should == 1
|
|
|
|
|
|
|
|
File.exist?(report).should be_false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-22 11:42:25 +00:00
|
|
|
describe 'tries to leave page' do
|
|
|
|
it "should not leave the page nor loop" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml --report #{report}}
|
|
|
|
$?.exitstatus.should == 1
|
|
|
|
|
|
|
|
report.should be_a_report_containing(2, 0, false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-22 13:40:40 +00:00
|
|
|
describe 'tries to click a button' do
|
|
|
|
it "should not leave the page nor loop" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml --report #{report}}
|
2011-07-22 16:48:51 +00:00
|
|
|
$?.exitstatus.should == 0
|
2011-07-22 13:40:40 +00:00
|
|
|
|
2011-07-22 16:48:51 +00:00
|
|
|
report.should be_a_report_containing(0, 0, false)
|
2011-07-22 13:40:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-10 15:02:26 +00:00
|
|
|
describe 'with filtered run' do
|
2011-06-10 15:10:09 +00:00
|
|
|
context "don't run a full run, just the filtered run" do
|
|
|
|
it "should succeed and run both" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --no-full-run --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
|
|
|
$?.exitstatus.should == 0
|
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(1, 0, false)
|
2011-06-10 15:10:09 +00:00
|
|
|
end
|
2011-06-23 13:29:07 +00:00
|
|
|
|
|
|
|
it "should use a file outside the normal test run and only run one" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_other_file.js}
|
|
|
|
$?.exitstatus.should == 0
|
|
|
|
|
|
|
|
report.should be_a_report_containing(1, 0, false)
|
|
|
|
end
|
2011-06-10 15:02:26 +00:00
|
|
|
end
|
|
|
|
|
2011-06-10 15:10:09 +00:00
|
|
|
context "do both runs" do
|
|
|
|
it "should fail and not run the second" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --report #{report} ./spec/jasmine/filtered_failure/failure_spec.js}
|
|
|
|
$?.exitstatus.should == 1
|
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(1, 1, false)
|
2011-06-10 15:10:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should succeed and run both" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
|
|
|
$?.exitstatus.should == 0
|
|
|
|
|
2011-06-16 13:51:49 +00:00
|
|
|
report.should be_a_report_containing(2, 0, false)
|
2011-06-10 15:10:09 +00:00
|
|
|
end
|
2011-06-24 19:57:00 +00:00
|
|
|
|
|
|
|
it "should succeed and run both, with the first having a console.log call" do
|
|
|
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success_with_console/success_one_spec.js}
|
|
|
|
$?.exitstatus.should == 2
|
|
|
|
|
|
|
|
report.should be_a_report_containing(2, 0, true)
|
|
|
|
end
|
2011-06-10 15:02:26 +00:00
|
|
|
end
|
|
|
|
end
|
2011-04-14 00:21:23 +00:00
|
|
|
end
|
|
|
|
|