Skip to content

Commit b574d9d

Browse files
committed
Make fill_options spec compatible with older Ruby
1 parent b9bd595 commit b574d9d

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

spec/feature/fill_options_spec.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Ported from https://github.com/teamcapybara/capybara/blob/3.40.0/spec/shared_selenium_session.rb
66
RSpec.describe 'fill_in options', sinatra: true do
77
before do
8+
# Ignore older versions without `#active_element` definition.
9+
skip if Gem::Version.new(Capybara::VERSION) < Gem::Version.new('3.36.0')
10+
811
sinatra.get '/' do
912
<<~HTML
1013
<!DOCTYPE html>
@@ -72,12 +75,14 @@
7275
end
7376

7477
it 'should fill in if the option is set via global option' do
75-
Capybara.default_set_options = { clear: :backspace }
76-
visit '/'
77-
fill_in('form_first_name', with: 'Thomas')
78-
expect(find(:fillable_field, 'form_first_name').value).to eq('Thomas')
79-
ensure
80-
Capybara.default_set_options = {}
78+
begin
79+
Capybara.default_set_options = { clear: :backspace }
80+
visit '/'
81+
fill_in('form_first_name', with: 'Thomas')
82+
expect(find(:fillable_field, 'form_first_name').value).to eq('Thomas')
83+
ensure
84+
Capybara.default_set_options = {}
85+
end
8186
end
8287

8388
it 'should only trigger onchange once' do

0 commit comments

Comments
 (0)