cucumber-rails 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e1cd2904e66669d6acf0468d21a4a3e28ac560bae247cf683f9c0e237e2cd11
4
- data.tar.gz: 7edc69638a3946df0ac20707ce080c45361b8cab885171ba370191d84f5268b3
3
+ metadata.gz: 02bbc6df3e0541e238dfedd61156318fc8766754bd66929553e41b3770507ed0
4
+ data.tar.gz: d9781472cfdebcaccec5fc0879698d486a06809d36809bc95c5624d36e13b6a0
5
5
  SHA512:
6
- metadata.gz: eda48ea91bc84b2d3a4008dc8424c79e5ab3173dfaab739ed309f75619f8741899c12ba67c0d221be73aa6f052ebd7fe60e7cded149cfa4d4de19b59bfc3633e
7
- data.tar.gz: 91f48677c021ad17c08b8a8fd50223c6942f7042ebfef1d68b3def47207cefecf73e45e5f955c881a3d180d9b8d821e87162bdd1dcaade16a702acbc66ed9bce
6
+ metadata.gz: 8868ff0ebe1844b2eae18b3b8b580ab00683790a7a02bc28aeb421b33ef4022eb4779478fff94de2f5abc80c068bdcdd098decdeab1b180dad37ae40bbe06ae2
7
+ data.tar.gz: 17ab8f1588d771f564aaec40a873e85f43d2b366674bb959bd4d2ddb4f519093f450f2411122498d8437d238a5b347483c34f9590a799d7f96d76ad790fd8e1b
data/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md)
2
2
  on how to contribute to Cucumber.
3
3
 
4
- ## [main](https://github.com/cucumber/cucumber-rails/compare/v2.5.0...main) (Not yet released)
4
+ ## [main](https://github.com/cucumber/cucumber-rails/compare/v2.5.1...main) (Not yet released)
5
5
 
6
6
  ### New Features
7
7
 
8
-
9
-
10
8
  ### Changed
11
9
 
10
+ ### Fixed
12
11
 
12
+ ## [v2.5.1](https://github.com/cucumber/cucumber-rails/compare/v2.5.0...v2.5.1) (2022-04-01)
13
13
 
14
14
  ### Fixed
15
15
 
16
- *
16
+ * Date input support in Rails 7 ([#535](https://github.com/cucumber/cucumber-rails/pull/535) [mgrunberg])
17
17
 
18
18
  ## [v2.5.0](https://github.com/cucumber/cucumber-rails/compare/v2.4.0...v2.5.0) (2022-03-07)
19
19
 
@@ -8,12 +8,13 @@ module Cucumber
8
8
  # Select a Rails date. Options hash must include from: +label+
9
9
  def select_date(date, options)
10
10
  date = Date.parse(date)
11
- if ::Rails::VERSION::MAJOR >= 7
12
- # Rails 7 generates date fields using input type="date". Capybara support's them
11
+ base_dom_id = get_base_dom_from_options(options)
12
+
13
+ # Rails 7 use HTML5 input type="date" by default. If input is not present fallback to plain select boxes alternative.
14
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
15
+ if html5_input_field_present?(base_dom_id)
13
16
  fill_in options[:from], with: date
14
17
  else
15
- base_dom_id = get_base_dom_id_from_label_tag(options[:from])
16
-
17
18
  find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
18
19
  find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
19
20
  find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
@@ -23,12 +24,13 @@ module Cucumber
23
24
  # Select a Rails time. Options hash must include from: +label+
24
25
  def select_time(time, options)
25
26
  time = Time.zone.parse(time)
26
- if ::Rails::VERSION::MAJOR >= 7
27
- # Rails 7 generates date fields using input type="time". Capybara support's them
27
+ base_dom_id = get_base_dom_from_options(options)
28
+
29
+ # Rails 7 use HTML5 input type="time" by default. If input is not present fallback to plain select boxes alternative.
30
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
31
+ if html5_input_field_present?(base_dom_id)
28
32
  fill_in options[:from], with: time
29
33
  else
30
- base_dom_id = get_base_dom_id_from_label_tag(options[:from])
31
-
32
34
  find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
33
35
  find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
34
36
  end
@@ -36,17 +38,29 @@ module Cucumber
36
38
 
37
39
  # Select a Rails datetime. Options hash must include from: +label+
38
40
  def select_datetime(datetime, options)
39
- if ::Rails::VERSION::MAJOR >= 7
40
- # Rails 7 generates datetime fields using input type="datetime-local". Capybara support's them
41
+ base_dom_id = get_base_dom_id_from_label_tag(options[:from])
42
+
43
+ # Rails 7 use HTML5 input type="datetime-local" by default. If input is not present fallback to plain select boxes alternative.
44
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
45
+ if html5_input_field_present?(base_dom_id)
41
46
  fill_in options[:from], with: DateTime.parse(datetime)
42
47
  else
43
- select_date(datetime, options)
44
- select_time(datetime, options)
48
+ extended_options = options.merge(base_dom_id: base_dom_id)
49
+ select_date(datetime, extended_options)
50
+ select_time(datetime, extended_options)
45
51
  end
46
52
  end
47
53
 
48
54
  private
49
55
 
56
+ def html5_input_field_present?(base_dom_id)
57
+ ::Rails::VERSION::MAJOR >= 7 && page.has_css?("##{base_dom_id}", wait: 0)
58
+ end
59
+
60
+ def get_base_dom_from_options(options)
61
+ options[:base_dom_id] || get_base_dom_id_from_label_tag(options[:from])
62
+ end
63
+
50
64
  # @example "event_starts_at_"
51
65
  def get_base_dom_id_from_label_tag(field)
52
66
  find(:xpath, ".//label[contains(., '#{field}')]")['for'].gsub(/(_[1-5]i)$/, '')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-03-07 00:00:00.000000000 Z
13
+ date: 2022-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara
@@ -374,10 +374,10 @@ licenses:
374
374
  - MIT
375
375
  metadata:
376
376
  bug_tracker_uri: https://github.com/cucumber/cucumber-rails/issues
377
- changelog_uri: https://github.com/cucumber/cucumber-rails/blob/v2.5.0/CHANGELOG.md
377
+ changelog_uri: https://github.com/cucumber/cucumber-rails/blob/v2.5.1/CHANGELOG.md
378
378
  documentation_uri: https://cucumber.io/docs
379
379
  mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
380
- source_code_uri: https://github.com/cucumber/cucumber-rails/tree/v2.5.0
380
+ source_code_uri: https://github.com/cucumber/cucumber-rails/tree/v2.5.1
381
381
  post_install_message:
382
382
  rdoc_options: []
383
383
  require_paths:
@@ -391,10 +391,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  requirements:
392
392
  - - ">="
393
393
  - !ruby/object:Gem::Version
394
- version: '0'
394
+ version: 1.6.1
395
395
  requirements: []
396
396
  rubygems_version: 3.1.2
397
397
  signing_key:
398
398
  specification_version: 4
399
- summary: cucumber-rails-2.5.0
399
+ summary: cucumber-rails-2.5.1
400
400
  test_files: []