2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#body' do
|
|
|
|
it "should return the unmodified page body" do
|
|
|
|
@session.visit('/')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_content('Hello world!') # wait for content to appear if visit is async
|
|
|
|
expect(@session.body).to include('Hello world!')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if "".respond_to?(:encoding)
|
|
|
|
context "encoding of response between ascii and utf8" do
|
|
|
|
it "should be valid with html entities" do
|
|
|
|
@session.visit('/with_html_entities')
|
2015-07-22 02:41:23 -04:00
|
|
|
expect(@session).to have_content('Encoding') # wait for content to appear if visit is async
|
2013-11-14 12:43:36 -05:00
|
|
|
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be valid without html entities" do
|
|
|
|
@session.visit('/with_html')
|
2015-07-22 02:41:23 -04:00
|
|
|
expect(@session).to have_content('This is a test') # wait for content to appear if visit is async
|
2013-11-14 12:43:36 -05:00
|
|
|
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|