2011-06-10 14:04:21 +00:00
RSpec . configure do | c |
c . mock_with :mocha
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-06-16 13:51:49 +00:00
RSpec :: Matchers . define :be_a_report_containing do | total , fails , used_console |
match do | filename |
2011-06-23 13:29:07 +00:00
parts ( filename ) . length . should == 4
2011-06-16 13:51:49 +00:00
parts [ 0 ] . should == total . to_s
parts [ 1 ] . should == fails . to_s
parts [ 2 ] . should == ( used_console ? " T " : " F " )
true
end
2011-06-23 13:29:07 +00:00
failure_message_for_should do | filename |
parts ( filename )
" expected #{ filename } to be a report containing ( #{ total } , #{ fails } , #{ used_console . inspect } ), instead it contained ( #{ parts [ 0 ] } , #{ parts [ 1 ] } , #{ ( parts [ 2 ] == " T " ) . inspect } ) "
end
def parts ( filename = nil )
2011-07-13 18:42:47 +00:00
@parts || = File . readlines ( filename ) . first . strip . split ( '/' )
end
end
RSpec :: Matchers . define :contain_a_failing_spec do | * parts |
match do | filename |
report ( filename ) . include? ( parts . join ( " || " ) ) . should be_true
end
def report ( filename )
@report || = File . readlines ( filename ) [ 1 .. - 1 ] . collect ( & :strip )
2011-06-23 13:29:07 +00:00
end
2011-06-16 13:51:49 +00:00
end
2011-06-16 14:11:37 +00:00