Rubocop cleanup

This commit is contained in:
Thomas Walpole 2018-06-19 13:57:42 -07:00
parent 86f1767f3c
commit 3a56e98319
19 changed files with 29 additions and 0 deletions

View File

@ -165,3 +165,6 @@ RSpec/FilePath:
RSpec/PredicateMatcher:
Enabled: false
Capybara/FeatureMethods:
Enabled: false

View File

@ -59,6 +59,7 @@ Capybara::SpecHelper.spec "#all" do
context "with css as default selector" do
before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do
expect(@session.all('h1').first.text).to eq('This is a test')
expect(@session.all("input[id='test_field']").first.value).to eq('monkey')
@ -102,6 +103,7 @@ Capybara::SpecHelper.spec "#all" do
expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
end
end
context ':minimum' do
it 'should succeed when the number of elements founds matches the expectation' do
expect { @session.all(:css, 'h1, p', minimum: 0) }.not_to raise_error
@ -110,6 +112,7 @@ Capybara::SpecHelper.spec "#all" do
expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
end
end
context ':maximum' do
it 'should succeed when the number of elements founds matches the expectation' do
expect { @session.all(:css, 'h1, p', maximum: 4) }.not_to raise_error
@ -118,6 +121,7 @@ Capybara::SpecHelper.spec "#all" do
expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
end
end
context ':between' do
it 'should succeed when the number of elements founds matches the expectation' do
expect { @session.all(:css, 'h1, p', between: 2..7) }.not_to raise_error

View File

@ -188,7 +188,9 @@ Capybara::SpecHelper.spec "#fill_in" do
context "with ignore_hidden_fields" do
before { Capybara.ignore_hidden_elements = true }
after { Capybara.ignore_hidden_elements = false }
it "should not find a hidden field" do
msg = "Unable to find visible field \"Super Secret\" that is not disabled"
expect do

View File

@ -206,6 +206,7 @@ Capybara::SpecHelper.spec '#find' do
context "with css as default selector" do
before { Capybara.default_selector = :css }
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')

View File

@ -51,6 +51,7 @@ Capybara::SpecHelper.spec '#first' do
context "with css as default selector" do
before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do
expect(@session.first('h1').text).to eq('This is a test')
expect(@session.first("input[id='test_field']").value).to eq('monkey')

View File

@ -185,6 +185,7 @@ Capybara::SpecHelper.spec "node" do
expect(@session.find('//option', text: 'Disabled Child Option')).to be_disabled
end
end
it "should be boolean" do
@session.visit('/form')
expect(@session.find('//select[@id="form_disabled_select"]/option').disabled?).to be true
@ -521,6 +522,7 @@ Capybara::SpecHelper.spec "node" do
describe '#reload', requires: [:js] do
context "without automatic reload" do
before { Capybara.automatic_reload = false }
it "should reload the current context of the node" do
@session.visit('/with_js')
node = @session.find(:css, '#reload-me')

View File

@ -69,6 +69,7 @@ Capybara::SpecHelper.spec '#save_page' do
context "asset_host contains a string" do
before { Capybara.asset_host = "http://example.com" }
after { Capybara.asset_host = nil }
it "prepends base tag with value from asset_host to the head" do

View File

@ -44,6 +44,7 @@ Capybara::SpecHelper.spec '#text' do
context "with css as default selector" do
before { Capybara.default_selector = :css }
it "should print the text of the page" do
@session.visit('/with_simple_html')
expect(@session.text).to eq('Bar')

View File

@ -8,6 +8,7 @@ Capybara::SpecHelper.spec '#title' do
context "with css as default selector" do
before { Capybara.default_selector = :css }
it "should get the title of the page" do
@session.visit('/with_title')
expect(@session.title).to eq('Test Title')

View File

@ -5,6 +5,7 @@ Capybara::SpecHelper.spec '#current_window', requires: [:windows] do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w

View File

@ -5,6 +5,7 @@ Capybara::SpecHelper.spec '#open_new_window', requires: [:windows] do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w

View File

@ -6,6 +6,7 @@ Capybara::SpecHelper.spec '#window_opened_by', requires: [:windows] do
@session.visit('/with_windows')
@session.assert_selector(:css, 'body.loaded')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w

View File

@ -5,6 +5,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w
@ -112,6 +113,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
before do
@initial_size = @session.current_window.size
end
after do
@session.current_window.resize_to(*@initial_size)
sleep 0.5
@ -143,6 +145,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
before do
@initial_size = @session.current_window.size
end
after do
@session.current_window.resize_to(*@initial_size)
sleep 0.5

View File

@ -10,6 +10,7 @@ Capybara::SpecHelper.spec '#windows', requires: [:windows] do
raise Capybara::CapybaraError if @session.windows.size != 3
end
end
after do
(@session.windows - [@window]).each(&:close)
@session.switch_to_window(@window)

View File

@ -10,6 +10,7 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
raise Capybara::CapybaraError if @session.windows.size != 3
end
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w

View File

@ -59,6 +59,7 @@ Capybara::SpecHelper.spec '#within' do
context "with the default selector set to CSS" do
before { Capybara.default_selector = :css }
it "should use CSS" do
@session.within("#for_bar li", text: 'With Simple HTML') do
@session.click_link('Go')

View File

@ -11,6 +11,7 @@ class MinitestSpecTest < Minitest::Spec
before do
visit('/form')
end
after do
Capybara.reset_sessions!
end

View File

@ -324,6 +324,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
context "with default selector CSS" do
before { Capybara.default_selector = :css }
it "fails if has_content? returns false" do
expect do
expect(page).to have_content('No such Text')
@ -459,6 +460,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
context "with default selector CSS" do
before { Capybara.default_selector = :css }
it "fails if has_text? returns false" do
expect do
expect(page).to have_text('No such Text')

View File

@ -73,6 +73,7 @@ RSpec.describe Capybara::Selenium::Driver do
before do
@original_browser = @driver.browser
end
after do
# Ensure browser is actually quit so we don't leave hanging processe
RSpec::Mocks.space.proxy_for(@original_browser).reset