2011-11-23 14:35:44 +00:00
|
|
|
if ENV['COVERAGE']
|
|
|
|
require 'simplecov'
|
|
|
|
SimpleCov.start
|
|
|
|
end
|
|
|
|
|
2011-11-29 14:45:23 +00:00
|
|
|
if ENV['PROFILE']
|
|
|
|
require 'perftools'
|
|
|
|
PerfTools::CpuProfiler.start("/tmp/jhw-profile")
|
|
|
|
end
|
|
|
|
|
2011-09-01 13:38:53 +00:00
|
|
|
require 'jasmine-headless-webkit'
|
|
|
|
require 'fakefs/spec_helpers'
|
|
|
|
|
2011-06-10 14:04:21 +00:00
|
|
|
RSpec.configure do |c|
|
|
|
|
c.mock_with :mocha
|
2011-11-25 23:11:21 +00:00
|
|
|
c.backtrace_clean_patterns = []
|
2011-09-01 14:39:29 +00:00
|
|
|
|
|
|
|
c.before(:each) do
|
|
|
|
Jasmine::Headless::CacheableAction.enabled = false
|
2011-11-18 16:50:48 +00:00
|
|
|
Jasmine::Headless::FilesList.reset!
|
2011-09-01 14:39:29 +00:00
|
|
|
end
|
2011-11-25 21:18:06 +00:00
|
|
|
|
|
|
|
c.before(:each, :type => :integration) do
|
|
|
|
let(:report) { 'spec/report.txt' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
FileUtils.rm_f report
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_f report
|
|
|
|
end
|
|
|
|
end
|
2011-06-10 14:04:21 +00:00
|
|
|
end
|
|
|
|
|
2011-04-14 00:21:23 +00:00
|
|
|
specrunner = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
|
|
|
|
|
|
|
|
if !File.file?(specrunner)
|
|
|
|
Dir.chdir File.split(specrunner).first do
|
|
|
|
system %{ruby extconf.rb}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-21 15:32:49 +00:00
|
|
|
class FakeFS::File
|
|
|
|
class << self
|
|
|
|
def fnmatch?(pattern, file)
|
|
|
|
RealFile.fnmatch?(pattern, file)
|
|
|
|
end
|
|
|
|
end
|
2011-11-25 23:11:21 +00:00
|
|
|
|
|
|
|
class Stat
|
|
|
|
def file?
|
|
|
|
File.file?(@file)
|
|
|
|
end
|
|
|
|
end
|
2011-11-21 15:32:49 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 13:38:53 +00:00
|
|
|
module RSpec::Matchers
|
2011-09-02 21:00:21 +00:00
|
|
|
define :be_a_report_containing do |total, failed, used_console|
|
2011-09-01 13:38:53 +00:00
|
|
|
match do |filename|
|
2011-09-02 21:00:21 +00:00
|
|
|
report(filename)
|
|
|
|
report.total.should == total
|
|
|
|
report.failed.should == failed
|
|
|
|
report.has_used_console?.should == used_console
|
2011-09-01 13:38:53 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
failure_message_for_should do |filename|
|
2011-09-02 21:00:21 +00:00
|
|
|
"expected #{filename} to be a report containing (#{total}, #{failed}, #{used_console.inspect})"
|
2011-09-01 13:38:53 +00:00
|
|
|
end
|
|
|
|
|
2011-09-02 21:00:21 +00:00
|
|
|
def report(filename = nil)
|
|
|
|
@report ||= Jasmine::Headless::Report.load(filename)
|
2011-09-01 13:38:53 +00:00
|
|
|
end
|
2011-06-23 13:29:07 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 13:38:53 +00:00
|
|
|
define :contain_a_failing_spec do |*parts|
|
|
|
|
match do |filename|
|
2011-09-02 21:00:21 +00:00
|
|
|
report(filename).should have_failed_on(parts.join(" "))
|
2011-09-01 13:38:53 +00:00
|
|
|
end
|
2011-07-13 18:42:47 +00:00
|
|
|
|
2011-09-01 13:38:53 +00:00
|
|
|
def report(filename)
|
2011-09-02 21:00:21 +00:00
|
|
|
@report ||= Jasmine::Headless::Report.load(filename)
|
2011-09-01 13:38:53 +00:00
|
|
|
end
|
2011-07-13 18:42:47 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 13:38:53 +00:00
|
|
|
define :be_a_file do
|
|
|
|
match do |file|
|
|
|
|
File.file?(file)
|
|
|
|
end
|
2011-06-23 13:29:07 +00:00
|
|
|
end
|
2011-11-18 03:16:04 +00:00
|
|
|
|
|
|
|
define :contain_in_order_in_file_list do |*files|
|
|
|
|
match do |lines|
|
|
|
|
file_list = files.dup
|
|
|
|
|
|
|
|
lines.each do |line|
|
|
|
|
next if !file_list.first
|
|
|
|
|
|
|
|
if line[file_list.first]
|
|
|
|
file_list.shift
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
file_list.length == 0
|
|
|
|
end
|
2011-11-18 16:50:48 +00:00
|
|
|
|
|
|
|
failure_message_for_should do |lines|
|
|
|
|
%{expected\n#{lines.join("\n")}\nto contain the following files, in order:\n#{files.join("\n")}}
|
|
|
|
end
|
2011-11-18 03:16:04 +00:00
|
|
|
end
|
2011-06-16 13:51:49 +00:00
|
|
|
end
|
2011-11-18 03:16:04 +00:00
|
|
|
|