2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-28 19:11:41 -05:00
|
|
|
|
2020-11-26 15:16:11 -05:00
|
|
|
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
2018-10-09 13:29:25 -04:00
|
|
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
|
|
|
# using Capybara provided assertions with builtin waiting behavior.
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#html' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the unmodified page body' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.visit('/')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.html).to include('Hello world!')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the current state of the page', requires: [:js] do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.visit('/with_js')
|
2018-10-09 13:29:25 -04:00
|
|
|
sleep 1
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.html).to include('I changed it')
|
|
|
|
expect(@session.html).not_to include('This is text')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
end
|
2012-11-20 08:22:19 -05:00
|
|
|
|
|
|
|
Capybara::SpecHelper.spec '#source' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the unmodified page source' do
|
2012-11-20 08:22:19 -05:00
|
|
|
@session.visit('/')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.source).to include('Hello world!')
|
2012-11-20 08:22:19 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the current state of the page', requires: [:js] do
|
2012-11-20 08:22:19 -05:00
|
|
|
@session.visit('/with_js')
|
2018-10-09 13:29:25 -04:00
|
|
|
sleep 1
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.source).to include('I changed it')
|
|
|
|
expect(@session.source).not_to include('This is text')
|
2012-11-20 08:22:19 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Capybara::SpecHelper.spec '#body' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the unmodified page source' do
|
2012-11-20 08:22:19 -05:00
|
|
|
@session.visit('/')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.body).to include('Hello world!')
|
2012-11-20 08:22:19 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the current state of the page', requires: [:js] do
|
2012-11-20 08:22:19 -05:00
|
|
|
@session.visit('/with_js')
|
2018-10-09 13:29:25 -04:00
|
|
|
sleep 1
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.body).to include('I changed it')
|
|
|
|
expect(@session.body).not_to include('This is text')
|
2012-11-20 08:22:19 -05:00
|
|
|
end
|
|
|
|
end
|