Minor code cleanup

This commit is contained in:
Thomas Walpole 2021-10-23 22:17:35 -07:00
parent 0e9c4aae37
commit 9856938e59
9 changed files with 10 additions and 9 deletions

View File

@ -75,7 +75,7 @@ module Capybara
filter = %r{lib/capybara/|lib/rspec/|lib/minitest/}
new_trace = trace.take_while { |line| line !~ filter }
new_trace = trace.reject { |line| line =~ filter } if new_trace.empty?
new_trace = trace.grep_v(filter) if new_trace.empty?
new_trace = trace.dup if new_trace.empty?
new_trace.first.split(/:in /, 2).first

View File

@ -216,7 +216,7 @@ private
min, max, step = (native['min'] || 0).to_f, (native['max'] || 100).to_f, (native['step'] || 1).to_f
value = value.to_f
value = value.clamp(min, max)
value = ((value - min) / step).round * step + min
value = (((value - min) / step).round * step) + min
native['value'] = value.clamp(min, max)
end

View File

@ -43,7 +43,7 @@ module Capybara
when '"', "'"
selector << parse_string(char, str)
when '\\'
selector << char + str.getc
selector << (char + str.getc)
when ','
selectors << selector.strip
selector.clear

View File

@ -63,6 +63,7 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
def visible?
return super unless native_displayed?
begin
bridge.send(:execute, :is_element_displayed, id: native_id)
rescue Selenium::WebDriver::Error::UnknownCommandError

View File

@ -356,7 +356,7 @@ Capybara::SpecHelper.spec '#has_no_text?' do
expect(@session).to have_no_text(/xxxxyzzz/)
end
it 'should be false if the text in the page matches given regexp' do
it 'should be false if the text in the page matches given regexp' do
@session.visit('/with_html')
expect(@session).not_to have_no_text(/Lorem/)
end

View File

@ -1115,7 +1115,7 @@ Capybara::SpecHelper.spec 'node' do
end
describe '#evaluate_script', requires: %i[js es_args] do
it 'should evaluate the given script in the context of the element and return whatever it produces' do
it 'should evaluate the given script in the context of the element and return whatever it produces' do
@session.visit('/with_js')
el = @session.find(:css, '#with_change_event')
expect(el.evaluate_script('this.value')).to eq('default value')

View File

@ -94,7 +94,7 @@ ffeature 'if ffeature aliases focused tag then' do # rubocop:disable RSpec/Focus
expect(example.metadata[:focus]).to eq true
end
scenario 'other scenarios also has metatag focus tag ' do |example|
scenario 'other scenarios also has metatag focus tag' do |example|
expect(example.metadata[:focus]).to eq true
end
end

View File

@ -59,8 +59,8 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
when 'Capybara::Session selenium #attach_file with multipart form should fire change once when uploading multiple files from empty'
pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
when 'Capybara::Session selenium #accept_confirm should work with nested modals'
skip 'Broken in 63 <= FF < 69 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session) && firefox_lt?(69, @session)
skip 'Hangs in 69 <= FF < 71 - Dont know what issue for this - previous issue was closed as fixed but it is not' if firefox_gte?(69, @session) && firefox_lt?(71, @session)
skip 'Broken in 63 <= FF < 69 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session) && firefox_lt?(69, @session)
skip 'Hangs in 69 <= FF < 71 - Dont know what issue for this - previous issue was closed as fixed but it is not' if firefox_gte?(69, @session) && firefox_lt?(71, @session)
skip 'Broken again intermittently in FF 71 - jus skip it'
when 'Capybara::Session selenium #click_link can download a file'
skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?

View File

@ -88,7 +88,7 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_sk
pending "Window 7 and 8.1 don't support 308 http status code"
when /#scroll_to can scroll an element to the center of the viewport$/,
/#scroll_to can scroll an element to the center of the scrolling element$/
pending " IE doesn't support ScrollToOptions"
pending "IE doesn't support ScrollToOptions"
when /#attach_file with multipart form should fire change once for each set of files uploaded$/,
/#attach_file with multipart form should fire change once when uploading multiple files from empty$/,
/#attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files$/