Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Oct 24, 2021
1 parent 0e9c4aa commit 9856938
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/capybara/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def filter_backtrace(trace)

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
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/rack_test/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def set_range(value) # rubocop:disable Naming/AccessorMethodName
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

Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector/css.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def split(css)
when '"', "'"
selector << parse_string(char, str)
when '\\'
selector << char + str.getc
selector << (char + str.getc)
when ','
selectors << selector.strip
selector.clear
Expand Down
1 change: 1 addition & 0 deletions lib/capybara/selenium/nodes/chrome_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def select_option

def visible?
return super unless native_displayed?

begin
bridge.send(:execute, :is_element_displayed, id: native_id)
rescue Selenium::WebDriver::Error::UnknownCommandError
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/has_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def to_hash; { value: 'Other hash' } end
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
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@
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')
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions spec/selenium_spec_firefox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ module TestSessions
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?
Expand Down
2 changes: 1 addition & 1 deletion spec/selenium_spec_ie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module TestSessions
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$/
Expand Down

0 comments on commit 9856938

Please sign in to comment.