Switching from nokogiri's hpricot mode to html mode and fixing bugs
This commit is contained in:
parent
eaa1c7fe25
commit
a7b230304c
1
TODO.txt
1
TODO.txt
@ -1,4 +1,3 @@
|
|||||||
Switch from Nokogiri::Hpricot to Nokogiri::HTML
|
|
||||||
Add tests for locator strategies
|
Add tests for locator strategies
|
||||||
Use Webrat::Methods for Merb and Rails integration
|
Use Webrat::Methods for Merb and Rails integration
|
||||||
Get file uploads workign with merb
|
Get file uploads workign with merb
|
||||||
|
@ -111,7 +111,7 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless id.blank?
|
unless id.blank?
|
||||||
@label_elements += @form.element / "label[@for=#{id}]"
|
@label_elements += @form.element.search("label[@for='#{id}']")
|
||||||
end
|
end
|
||||||
|
|
||||||
@label_elements
|
@label_elements
|
||||||
@ -311,8 +311,9 @@ module Webrat
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def default_value
|
def default_value
|
||||||
selected_options = @element / "option[@selected='selected']"
|
selected_options = @element / ".//option[@selected='selected']"
|
||||||
selected_options = @element / "option:first" if selected_options.empty?
|
selected_options = @element / ".//option[position() = 1]" if selected_options.empty?
|
||||||
|
|
||||||
selected_options.map do |option|
|
selected_options.map do |option|
|
||||||
return "" if option.nil?
|
return "" if option.nil?
|
||||||
option["value"] || option.inner_html
|
option["value"] || option.inner_html
|
||||||
@ -324,7 +325,7 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def option_elements
|
def option_elements
|
||||||
(@element / "option")
|
(@element / ".//option")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ module Webrat
|
|||||||
def fields
|
def fields
|
||||||
return @fields if @fields
|
return @fields if @fields
|
||||||
|
|
||||||
@fields = (@element / "button, input, textarea, select").collect do |field_element|
|
@fields = (@element.search(".//button", ".//input", ".//textarea", ".//select")).collect do |field_element|
|
||||||
Field.class_for_element(field_element).new(self, field_element)
|
Field.class_for_element(field_element).new(self, field_element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ module Webrat
|
|||||||
alias_method :clicks_button, :click_button
|
alias_method :clicks_button, :click_button
|
||||||
|
|
||||||
def dom # :nodoc:
|
def dom # :nodoc:
|
||||||
@dom ||= Nokogiri::Hpricot(scoped_html)
|
@dom ||= Nokogiri::HTML(scoped_html)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -155,7 +155,7 @@ module Webrat
|
|||||||
def scoped_html
|
def scoped_html
|
||||||
@scoped_html ||= begin
|
@scoped_html ||= begin
|
||||||
if @selector
|
if @selector
|
||||||
(Nokogiri::Hpricot(@html) / @selector).first.to_html
|
(Nokogiri::HTML(@html) / @selector).first.to_html
|
||||||
else
|
else
|
||||||
@html
|
@html
|
||||||
end
|
end
|
||||||
|
@ -3,12 +3,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|||||||
module Webrat
|
module Webrat
|
||||||
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
|
||||||
checkbox = CheckboxField.new(nil, (Nokogiri::Hpricot("<input type='checkbox' checked='checked'>")/'input').first)
|
checkbox = CheckboxField.new(nil, (Nokogiri::HTML("<input type='checkbox' checked='checked'>")/'input').first)
|
||||||
checkbox.should be_checked
|
checkbox.should be_checked
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should say it is not checked if it is not" do
|
it "should say it is not checked if it is not" do
|
||||||
checkbox = CheckboxField.new(nil, (Nokogiri::Hpricot("<input type='checkbox'>")/'input').first)
|
checkbox = CheckboxField.new(nil, (Nokogiri::HTML("<input type='checkbox'>")/'input').first)
|
||||||
checkbox.should_not be_checked
|
checkbox.should_not be_checked
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user