Skip to content

Commit

Permalink
Revert "include Webrat::Matchers in selinium mode"
Browse files Browse the repository at this point in the history
And Revert "getting assert_* to work with selenium"
  • Loading branch information
adkron committed Jan 10, 2009
1 parent 10b31be commit 928b224
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/webrat/selenium.rb
Expand Up @@ -88,7 +88,6 @@ module ActionController #:nodoc:
IntegrationTest.class_eval do
include Webrat::Methods
include Webrat::Selenium::Methods
include Webrat::Matchers
include Webrat::Selenium::Matchers
end
end
31 changes: 31 additions & 0 deletions lib/webrat/selenium/matchers.rb
Expand Up @@ -59,6 +59,10 @@ def have_selector(content)
end

class HasContent #:nodoc:
def initialize(content)
@content = content
end

def matches?(response)
if @content.is_a?(Regexp)
text_finder = "regexp:#{@content.source}"
Expand All @@ -70,6 +74,33 @@ def matches?(response)
response.selenium.is_text_present(text_finder)
end
end

# ==== Returns
# String:: The failure message.
def failure_message
"expected the following element's content to #{content_message}:\n#{@element}"
end

# ==== Returns
# String:: The failure message to be displayed in negative matches.
def negative_failure_message
"expected the following element's content to not #{content_message}:\n#{@element}"
end

def content_message
case @content
when String
"include \"#{@content}\""
when Regexp
"match #{@content.inspect}"
end
end
end

# Matches the contents of an HTML document with
# whatever string is supplied
def contain(content)
HasContent.new(content)
end

end
Expand Down

0 comments on commit 928b224

Please sign in to comment.