RSpec cleanup
This commit is contained in:
parent
fcc94a43f5
commit
4ebb92dfdd
|
@ -208,11 +208,12 @@ Capybara::SpecHelper.spec '#find' do
|
|||
context 'with css as default selector' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'should find the first element using the given locator' do
|
||||
expect(@session.find('h1').text).to eq('This is a test')
|
||||
expect(@session.find("input[id='test_field']").value).to eq('monkey')
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
|
||||
it 'should raise ElementNotFound with a useful default message if nothing was found' do
|
||||
|
|
|
@ -545,6 +545,8 @@ Capybara::SpecHelper.spec 'node' do
|
|||
context 'without automatic reload' do
|
||||
before { Capybara.automatic_reload = false }
|
||||
|
||||
after { Capybara.automatic_reload = true }
|
||||
|
||||
it 'should reload the current context of the node' do
|
||||
@session.visit('/with_js')
|
||||
node = @session.find(:css, '#reload-me')
|
||||
|
@ -574,7 +576,6 @@ Capybara::SpecHelper.spec 'node' do
|
|||
expect(error).to be_an_invalid_element_error(@session)
|
||||
end)
|
||||
end
|
||||
after { Capybara.automatic_reload = true }
|
||||
end
|
||||
|
||||
context 'with automatic reload' do
|
||||
|
|
|
@ -87,6 +87,10 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|||
Capybara.reuse_server = false
|
||||
end
|
||||
|
||||
after do
|
||||
Capybara.reuse_server = @reuse_server
|
||||
end
|
||||
|
||||
it 'raises any standard errors caught inside the server during a second session', requires: [:server] do
|
||||
Capybara.using_driver(@session.mode) do
|
||||
Capybara.using_session(:another_session) do
|
||||
|
@ -100,10 +104,6 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
after do
|
||||
Capybara.reuse_server = @reuse_server
|
||||
end
|
||||
end
|
||||
|
||||
it 'raises configured errors caught inside the server', requires: [:server] do
|
||||
|
|
|
@ -45,11 +45,12 @@ Capybara::SpecHelper.spec '#text' do
|
|||
context 'with css as default selector' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'should print the text of the page' do
|
||||
@session.visit('/with_simple_html')
|
||||
expect(@session.text).to eq('Bar')
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
|
||||
it 'should be correctly normalized when visible' do
|
||||
|
|
|
@ -9,11 +9,12 @@ Capybara::SpecHelper.spec '#title' do
|
|||
context 'with css as default selector' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'should get the title of the page' do
|
||||
@session.visit('/with_title')
|
||||
expect(@session.title).to eq('Test Title')
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
|
||||
context 'within iframe', requires: [:frames] do
|
||||
|
|
|
@ -60,13 +60,14 @@ Capybara::SpecHelper.spec '#within' do
|
|||
context 'with the default selector set to CSS' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'should use CSS' do
|
||||
@session.within('#for_bar li', text: 'With Simple HTML') do
|
||||
@session.click_link('Go')
|
||||
end
|
||||
expect(@session).to have_content('Bar')
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
|
||||
context 'with nested scopes' do
|
||||
|
|
|
@ -40,6 +40,10 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|||
end
|
||||
|
||||
describe '#click_link' do
|
||||
after do
|
||||
@session.driver.options[:respect_data_method] = false
|
||||
end
|
||||
|
||||
it 'should use data-method if option is true' do
|
||||
@session.driver.options[:respect_data_method] = true
|
||||
@session.visit '/with_html'
|
||||
|
@ -60,10 +64,6 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|||
@session.click_link 'A link with capitalized data-method'
|
||||
expect(@session.html).to include('The requested object was deleted')
|
||||
end
|
||||
|
||||
after do
|
||||
@session.driver.options[:respect_data_method] = false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#fill_in' do
|
||||
|
|
|
@ -325,12 +325,13 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|||
context 'with default selector CSS' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'fails if has_content? returns false' do
|
||||
expect do
|
||||
expect(page).to have_content('No such Text')
|
||||
end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -461,12 +462,13 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|||
context 'with default selector CSS' do
|
||||
before { Capybara.default_selector = :css }
|
||||
|
||||
after { Capybara.default_selector = :xpath }
|
||||
|
||||
it 'fails if has_text? returns false' do
|
||||
expect do
|
||||
expect(page).to have_text('No such Text')
|
||||
end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
|
||||
end
|
||||
after { Capybara.default_selector = :xpath }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue