Created
January 8, 2012 12:22
-
-
Save gaizka/1578175 to your computer and use it in GitHub Desktop.
Maybe Capybara <-> Nokogiri bug, inserting extra xml declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'capybara' | |
require 'capybara/rspec' | |
require 'sinatra' | |
class TestApp < Sinatra::Base | |
set :root, File.dirname(__FILE__) | |
set :static, true | |
get '/' do | |
'Hello world!' | |
end | |
get '/iframe_content' do | |
'<iframe src=\"xx.html\"></iframe>' | |
end | |
get '/accented_content' do | |
'¡Leñe!' | |
end | |
end | |
describe "Capybara inserts <?xml version=\"1.0\" standalone=\"yes\"?> line" do | |
before do | |
Capybara.app = TestApp | |
end | |
let(:session) { Capybara::Session.new(:rack_test, TestApp) } | |
it "and this breaks '<iframe></iframe>' parsing, for example" do | |
session.visit('/iframe_content') | |
session.body.should =~ /<iframe.*<\/iframe>/ | |
end | |
it "it also breaks accented characters" do | |
session.visit('/accented_content') | |
session.body.should include("¡Leñe!") | |
end | |
it "this will work in places with xml header, but not in others" do | |
session.visit('/accented_content') | |
session.body.should include("¡Leñe!") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment