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: RSpec/PredicateMatcher:
Enabled: false Enabled: false
Capybara/FeatureMethods:
Enabled: false

View File

@ -59,6 +59,7 @@ Capybara::SpecHelper.spec "#all" do
context "with css as default selector" do context "with css as default selector" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do 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('h1').first.text).to eq('This is a test')
expect(@session.all("input[id='test_field']").first.value).to eq('monkey') 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) expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
end end
end end
context ':minimum' do context ':minimum' do
it 'should succeed when the number of elements founds matches the expectation' 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 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) expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
end end
end end
context ':maximum' do context ':maximum' do
it 'should succeed when the number of elements founds matches the expectation' 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 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) expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
end end
end end
context ':between' do context ':between' do
it 'should succeed when the number of elements founds matches the expectation' 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 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 context "with ignore_hidden_fields" do
before { Capybara.ignore_hidden_elements = true } before { Capybara.ignore_hidden_elements = true }
after { Capybara.ignore_hidden_elements = false } after { Capybara.ignore_hidden_elements = false }
it "should not find a hidden field" do it "should not find a hidden field" do
msg = "Unable to find visible field \"Super Secret\" that is not disabled" msg = "Unable to find visible field \"Super Secret\" that is not disabled"
expect do expect do

View File

@ -206,6 +206,7 @@ Capybara::SpecHelper.spec '#find' do
context "with css as default selector" do context "with css as default selector" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do 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('h1').text).to eq('This is a test')
expect(@session.find("input[id='test_field']").value).to eq('monkey') 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 context "with css as default selector" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do 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('h1').text).to eq('This is a test')
expect(@session.first("input[id='test_field']").value).to eq('monkey') 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 expect(@session.find('//option', text: 'Disabled Child Option')).to be_disabled
end end
end end
it "should be boolean" do it "should be boolean" do
@session.visit('/form') @session.visit('/form')
expect(@session.find('//select[@id="form_disabled_select"]/option').disabled?).to be true 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 describe '#reload', requires: [:js] do
context "without automatic reload" do context "without automatic reload" do
before { Capybara.automatic_reload = false } before { Capybara.automatic_reload = false }
it "should reload the current context of the node" do it "should reload the current context of the node" do
@session.visit('/with_js') @session.visit('/with_js')
node = @session.find(:css, '#reload-me') 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 context "asset_host contains a string" do
before { Capybara.asset_host = "http://example.com" } before { Capybara.asset_host = "http://example.com" }
after { Capybara.asset_host = nil } after { Capybara.asset_host = nil }
it "prepends base tag with value from asset_host to the head" do 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 context "with css as default selector" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should print the text of the page" do it "should print the text of the page" do
@session.visit('/with_simple_html') @session.visit('/with_simple_html')
expect(@session.text).to eq('Bar') expect(@session.text).to eq('Bar')

View File

@ -8,6 +8,7 @@ Capybara::SpecHelper.spec '#title' do
context "with css as default selector" do context "with css as default selector" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should get the title of the page" do it "should get the title of the page" do
@session.visit('/with_title') @session.visit('/with_title')
expect(@session.title).to eq('Test 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 @window = @session.current_window
@session.visit('/with_windows') @session.visit('/with_windows')
end end
after do after do
(@session.windows - [@window]).each do |w| (@session.windows - [@window]).each do |w|
@session.switch_to_window 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 @window = @session.current_window
@session.visit('/with_windows') @session.visit('/with_windows')
end end
after do after do
(@session.windows - [@window]).each do |w| (@session.windows - [@window]).each do |w|
@session.switch_to_window 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.visit('/with_windows')
@session.assert_selector(:css, 'body.loaded') @session.assert_selector(:css, 'body.loaded')
end end
after do after do
(@session.windows - [@window]).each do |w| (@session.windows - [@window]).each do |w|
@session.switch_to_window w @session.switch_to_window w

View File

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

View File

@ -10,6 +10,7 @@ Capybara::SpecHelper.spec '#windows', requires: [:windows] do
raise Capybara::CapybaraError if @session.windows.size != 3 raise Capybara::CapybaraError if @session.windows.size != 3
end end
end end
after do after do
(@session.windows - [@window]).each(&:close) (@session.windows - [@window]).each(&:close)
@session.switch_to_window(@window) @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 raise Capybara::CapybaraError if @session.windows.size != 3
end end
end end
after do after do
(@session.windows - [@window]).each do |w| (@session.windows - [@window]).each do |w|
@session.switch_to_window 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 context "with the default selector set to CSS" do
before { Capybara.default_selector = :css } before { Capybara.default_selector = :css }
it "should use CSS" do it "should use CSS" do
@session.within("#for_bar li", text: 'With Simple HTML') do @session.within("#for_bar li", text: 'With Simple HTML') do
@session.click_link('Go') @session.click_link('Go')

View File

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

View File

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

View File

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