Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
gemfile: [ 'rails_5_0', 'rails_5_1', 'rails_5_2', 'rails_6_0', 'rails_6_1' ]
gemfile: [ 'rails_5_0', 'rails_5_1', 'rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0' ]
exclude:
# Only test latest Rails (Of each major), on actively supported Ruby Versions
# Only test latest Ruby with latest Rails versions (Of each major)
Expand All @@ -20,10 +20,13 @@ jobs:
- { ruby: '2.4', gemfile: 'rails_5_2' }
- { ruby: '2.4', gemfile: 'rails_6_0' }
- { ruby: '2.4', gemfile: 'rails_6_1' }
- { ruby: '2.4', gemfile: 'rails_7_0' }
- { ruby: '2.5', gemfile: 'rails_5_2' }
- { ruby: '2.5', gemfile: 'rails_6_1' }
- { ruby: '2.5', gemfile: 'rails_7_0' }
- { ruby: '2.6', gemfile: 'rails_5_0' }
- { ruby: '2.6', gemfile: 'rails_5_1' }
- { ruby: '2.6', gemfile: 'rails_7_0' }
- { ruby: '2.7', gemfile: 'rails_5_0' }
- { ruby: '2.7', gemfile: 'rails_5_1' }
- { ruby: '3.0', gemfile: 'rails_5_0' }
Expand Down
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ appraise 'rails_6_1' do
gem 'activerecord'
gem 'sqlite3', '~> 1.4'
end

appraise 'rails_7_0' do
gem 'railties', '~> 7.0.0'
gem 'activerecord'
gem 'sqlite3', '~> 1.4'
end
2 changes: 1 addition & 1 deletion cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('cucumber', ['>= 3.2', '< 8']) # Support cucumber in the 3.x <-> 7.x revision range
s.add_runtime_dependency('mime-types', ['~> 3.3']) # Only support the latest major (3+ years old)
s.add_runtime_dependency('nokogiri', '~> 1.10') # Only support the latest major (3+ years old)
s.add_runtime_dependency('railties', ['>= 5.0', '< 7']) # We support any version of Rails in the 5.x and 6.x series
s.add_runtime_dependency('railties', ['>= 5.0', '< 8']) # We support any version of Rails in the 5.x, 6.x and 7.x series
s.add_runtime_dependency('rexml', '~> 3.0') # rexml is a bundled gem from ruby 3
s.add_runtime_dependency('webrick', '~> 1.7') # webrick is a bundled gem from ruby 3

Expand Down
19 changes: 16 additions & 3 deletions features/emulate_javascript.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ Feature: Emulate Javascript
Scenario: Delete a widget
Given there is a widget named "wrench"
And I am on the session establish page
And I am on the widgets page
And I navigate to destroy "wrench" page
Then I should see "wrench"
And I should see "Destroy"
When I follow "Destroy"
Then I should not see "denied"
And I should be on the widgets page
Expand All @@ -87,8 +88,20 @@ Feature: Emulate Javascript
visit session_establish_path
end

Given('I navigate to destroy {string} page') do |name|
if ::Rails::VERSION::MAJOR >= 7
visit widget_path(Widget.find_by(name: name))
else
visit widgets_path
end
end

When('I follow {string}') do |link|
click_link(link)
if ::Rails::VERSION::MAJOR >= 7
click_button(link)
else
click_link(link)
end
end

Then('I should not see {string}') do |text|
Expand All @@ -105,5 +118,5 @@ Feature: Emulate Javascript
Then the feature run should pass with:
"""
1 scenario (1 passed)
8 steps (8 passed)
9 steps (9 passed)
"""
9 changes: 9 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "railties", "~> 7.0.0"
gem "activerecord"
gem "sqlite3", "~> 1.4"

gemspec path: "../"
41 changes: 28 additions & 13 deletions lib/cucumber/rails/capybara/select_dates_and_times.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,42 @@ module Capybara
module SelectDatesAndTimes
# Select a Rails date. Options hash must include from: +label+
def select_date(date, options)
date = Date.parse(date)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])

find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
date = Date.parse(date)
if ::Rails::VERSION::MAJOR >= 7
# Rails 7 generates date fields using input type="date". Capybara support's them
fill_in options[:from], with: date
else
base_dom_id = get_base_dom_id_from_label_tag(options[:from])

find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
end
end

# Select a Rails time. Options hash must include from: +label+
def select_time(time, options)
time = Time.zone.parse(time)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])

find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
time = Time.zone.parse(time)
if ::Rails::VERSION::MAJOR >= 7
# Rails 7 generates date fields using input type="time". Capybara support's them
fill_in options[:from], with: time
else
base_dom_id = get_base_dom_id_from_label_tag(options[:from])

find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
end
end

# Select a Rails datetime. Options hash must include from: +label+
def select_datetime(datetime, options)
select_date(datetime, options)
select_time(datetime, options)
if ::Rails::VERSION::MAJOR >= 7
# Rails 7 generates datetime fields using input type="datetime-local". Capybara support's them
fill_in options[:from], with: DateTime.parse(datetime)
else
select_date(datetime, options)
select_time(datetime, options)
end
end

private
Expand Down