Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gaizka/1578175 to your computer and use it in GitHub Desktop.
Save gaizka/1578175 to your computer and use it in GitHub Desktop.
Maybe Capybara <-> Nokogiri bug, inserting extra xml declaration
# 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("&#xA1;Le&#xF1;e!")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment