mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 17:50:13 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
70
vendor/plugins/rspec/lib/spec/matchers/include.rb
vendored
Normal file
70
vendor/plugins/rspec/lib/spec/matchers/include.rb
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
module Spec
|
||||
module Matchers
|
||||
|
||||
class Include #:nodoc:
|
||||
|
||||
def initialize(*expecteds)
|
||||
@expecteds = expecteds
|
||||
end
|
||||
|
||||
def matches?(actual)
|
||||
@actual = actual
|
||||
@expecteds.each do |expected|
|
||||
return false unless actual.include?(expected)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def failure_message
|
||||
_message
|
||||
end
|
||||
|
||||
def negative_failure_message
|
||||
_message("not ")
|
||||
end
|
||||
|
||||
def description
|
||||
"include #{_pretty_print(@expecteds)}"
|
||||
end
|
||||
|
||||
private
|
||||
def _message(maybe_not="")
|
||||
"expected #{@actual.inspect} #{maybe_not}to include #{_pretty_print(@expecteds)}"
|
||||
end
|
||||
|
||||
def _pretty_print(array)
|
||||
result = ""
|
||||
array.each_with_index do |item, index|
|
||||
if index < (array.length - 2)
|
||||
result << "#{item.inspect}, "
|
||||
elsif index < (array.length - 1)
|
||||
result << "#{item.inspect} and "
|
||||
else
|
||||
result << "#{item.inspect}"
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
# :call-seq:
|
||||
# should include(expected)
|
||||
# should_not include(expected)
|
||||
#
|
||||
# Passes if actual includes expected. This works for
|
||||
# collections and Strings. You can also pass in multiple args
|
||||
# and it will only pass if all args are found in collection.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# [1,2,3].should include(3)
|
||||
# [1,2,3].should include(2,3) #would pass
|
||||
# [1,2,3].should include(2,3,4) #would fail
|
||||
# [1,2,3].should_not include(4)
|
||||
# "spread".should include("read")
|
||||
# "spread".should_not include("red")
|
||||
def include(*expected)
|
||||
Matchers::Include.new(*expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue