Better inspect output for Webrat elements

This commit is contained in:
Bryan Helmkamp 2008-12-12 15:43:27 -05:00
parent 2d427ed89e
commit a5e6af2fe7
3 changed files with 19 additions and 0 deletions

View File

@ -17,6 +17,7 @@
* Minor enhancements * Minor enhancements
* Better inspect output for Webrat elements
* Detect if the document is XML or HTML using the Content-Type when in Rails mode * Detect if the document is XML or HTML using the Content-Type when in Rails mode
* Expose #selenium method for direct access to Selenium client * Expose #selenium method for direct access to Selenium client
* Check nokogiri gem version before requiring nokogiri * Check nokogiri gem version before requiring nokogiri

View File

@ -24,6 +24,10 @@ module Webrat
Webrat::XML.xpath_to(@element) Webrat::XML.xpath_to(@element)
end end
def inspect
"#<#{self.class} @element=#{element.inspect}>"
end
end end
end end

View File

@ -1,6 +1,20 @@
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper") require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
module Webrat module Webrat
describe Field do
it "should have nice inspect output" do
html = <<-HTML
<html>
<input type='checkbox' checked='checked' />
</html>
HTML
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
checkbox = CheckboxField.new(nil, element)
checkbox.inspect.should =~ /#<Webrat::CheckboxField @element=<input type=['"]checkbox['"] checked=['"]checked['"]\/>>/
end
end
describe CheckboxField do describe CheckboxField do
it "should say it is checked if it is" do it "should say it is checked if it is" do
html = <<-HTML html = <<-HTML