Skip to content

Commit

Permalink
Merge remote branch 'JonathanTron/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed May 9, 2010
2 parents 32c0c88 + 9401ecb commit b1e1982
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/capybara/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def all(*args)
results = all_unfiltered(locator)

if options[:text]
options[:text] = Regexp.escape(options[:text]) unless options[:text].kind_of?(Regexp)
results = results.select { |n| n.text.match(options[:text]) }
end

Expand Down
9 changes: 7 additions & 2 deletions spec/searchable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def all_unfiltered(locator, options = {})

context "with :text filter" do
before do
@node1 = stub(Node, :text => 'node one text')
@node2 = stub(Node, :text => 'node two text')
@node1 = stub(Node, :text => 'node one text (with parens)')
@node2 = stub(Node, :text => 'node two text [-]')
@searchable.stub(:all_unfiltered).and_return([@node1, @node2])
end

Expand All @@ -40,6 +40,11 @@ def all_unfiltered(locator, options = {})
@searchable.all('//x', :text => "node one").should == [@node1]
@searchable.all('//x', :text => "node two").should == [@node2]
end

it "should allow Regexp reserved words in text" do
@searchable.all('//x', :text => "node one text (with parens)").should == [@node1]
@searchable.all('//x', :text => "node two text [-]").should == [@node2]
end
end

context "with :visible filter" do
Expand Down

0 comments on commit b1e1982

Please sign in to comment.