Make "should contain" ignore extra whitespace when doing string comparisons
This commit is contained in:
parent
f9985cd488
commit
db168bedec
|
@ -1,5 +1,6 @@
|
|||
* Bug fixes
|
||||
|
||||
|
||||
* Make "should contain" ignore extra whitespace when doing string comparisons (Noah Davis)
|
||||
* Make selenium matchers handle negative match more consistently with positive match (Luke Melia)
|
||||
|
||||
== 0.6.0 / 2009-11-28
|
||||
|
|
|
@ -12,7 +12,7 @@ module Webrat
|
|||
|
||||
case @content
|
||||
when String
|
||||
@element.include?(@content)
|
||||
@element.gsub(/\s+/, ' ').include?(@content)
|
||||
when Regexp
|
||||
@element.match(@content)
|
||||
end
|
||||
|
|
|
@ -3,21 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|||
describe "contain" do
|
||||
include Webrat::Matchers
|
||||
|
||||
before(:each) do
|
||||
@body = <<-HTML
|
||||
<div id='main'>
|
||||
<div class='inner'>hello, world!</div>
|
||||
<h2>Welcome "Bryan"</h2>
|
||||
<h3>Welcome 'Bryan'</h3>
|
||||
<h4>Welcome 'Bryan"</h4>
|
||||
<ul>
|
||||
<li>First</li>
|
||||
<li>Second</li>
|
||||
</ul>
|
||||
</div>
|
||||
HTML
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
@body = <<-EOF
|
||||
<div id='main'>
|
||||
|
@ -34,6 +19,14 @@ describe "contain" do
|
|||
it "should call element#matches? when the argument is a regular expression" do
|
||||
@body.should contain(/hello, world/)
|
||||
end
|
||||
|
||||
it "should treat newlines as spaces" do
|
||||
"<div>it takes\ndifferent strokes</div>".should contain("it takes different strokes")
|
||||
end
|
||||
|
||||
it "should multiple spaces as a single space" do
|
||||
"<div>it takes different strokes</div>".should contain("it takes different strokes")
|
||||
end
|
||||
end
|
||||
|
||||
describe "asserts for contains," do
|
||||
|
|
Loading…
Reference in New Issue