diff --git a/lib/capybara/driver/webkit/node.rb b/lib/capybara/driver/webkit/node.rb index 9102cd5b..dc293b3b 100644 --- a/lib/capybara/driver/webkit/node.rb +++ b/lib/capybara/driver/webkit/node.rb @@ -1,7 +1,10 @@ class Capybara::Driver::Webkit class Node < Capybara::Driver::Node + NBSP = "\xC2\xA0" + NBSP.force_encoding("UTF-8") if NBSP.respond_to?(:force_encoding) + def text - invoke "text" + invoke("text").gsub(NBSP, ' ').gsub(/\s+/u, ' ').strip end def [](name) diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 5b3feba5..1e3d3794 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -159,6 +159,7 @@ +
Spaces not normalized 
Can't see me
@@ -202,6 +203,10 @@ subject.find("//p").first.text.should == "hello" end + it "normalizes a node's text" do + subject.find("//div[contains(@class, 'normalize')]").first.text.should == "Spaces not normalized" + end + it "returns the current URL" do port = subject.instance_variable_get("@rack_server").port subject.current_url.should == "http://127.0.0.1:#{port}/hello/world?success=true"