capybara-bootstrap-datepicker 0.2.4 → 1.0.0

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: 336efdfdf59a5b5d8924c2bf77b7832788347e9e509ce9ff61e31eda00cc8a7a
4
- data.tar.gz: b17cf6191ff8b1d2edc9bb1e729698aa8a952653de3b9ee4d8ea565d0350db1f
3
+ metadata.gz: 5e2f252653c8d07a778d0f69880c097c77820ed48ffd6b7f3110b395ee480d9e
4
+ data.tar.gz: 787eaad6e7813c365ef327d6970f741756473c65fa883df673847c4534d1f771
5
5
  SHA512:
6
- metadata.gz: d92949432a9da1a0ed1a64bb363dfe86e6950a8400faab21b2ab384be44847af5d090bd4bb4c7c8b61b9123a9499c39e02b516cd5f2fd321e1376481c4367c91
7
- data.tar.gz: bb4073b26ff64f7b7ebe37e0929377063f3a6c0da9f628be4b8f4008946dfad36092483f4fc7e2865bf3011d1a0f582a8fd78cd8ea0275eff812d187fc832989
6
+ metadata.gz: 86c11d819faf992351e96417457aeb7f1cff20d02575a13782cded1d7054ade3fc7793330ff37e3b7f9818a68cab9f7b138ad8bc3ce8448ed2c085315274adef
7
+ data.tar.gz: 3e7304437631dbea21a9bd69b621f614716f0700a880e4393a0806a87d110e86e9425d1eface263c7c3bdbafda11cce979cd9fb3e0d80df577f8f9818c13c894
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
4
+ # configuration file. It makes it possible to enable/disable
5
+ # certain cops (checks) and to alter their behavior if they accept
6
+ # any parameters. The file can be placed either in your home
7
+ # directory or in some project directory.
8
+ #
9
+ # RuboCop will start looking for the configuration file in the directory
10
+ # where the inspected file is and continue its way up to the root directory.
11
+ #
12
+ # See https://docs.rubocop.org/rubocop/configuration
13
+
14
+ plugins:
15
+ - rubocop-performance
16
+ - rubocop-rspec
17
+ - rubocop-capybara
18
+
19
+ AllCops:
20
+ NewCops: enable
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,27 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-03-30 18:11:21 UTC using RuboCop version 1.75.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
+ Metrics/AbcSize:
12
+ Max: 18
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
16
+ Metrics/ParameterLists:
17
+ Max: 6
18
+
19
+ # Offense count: 2
20
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
21
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
22
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
23
+ Naming/FileName:
24
+ Exclude:
25
+ - 'Rakefile.rb'
26
+ - 'lib/capybara-bootstrap-datepicker.rb'
27
+ - 'lib/capybara/bootstrap-datepicker.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.9
1
+ 3.4.1
data/Gemfile CHANGED
@@ -5,5 +5,15 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in capybara-bootstrap-datepicker.gemspec
6
6
  gemspec
7
7
 
8
- gem 'nokogiri', '>= 1.6.7.2'
9
- gem 'rack', '>= 1.6.11'
8
+ gem 'base64', '~> 0.2.0'
9
+ gem 'capybara', '~> 3.29', '>= 3.29.0'
10
+ gem 'capybara-screenshot', '~> 1.0', '>= 1.0.22'
11
+ gem 'nokogiri', '~> 1.18', '>= 1.18.6'
12
+ gem 'rack', '~> 3.1', '>= 3.1.12'
13
+ gem 'rspec', '~> 3.9', '>= 3.9.0'
14
+ gem 'rubocop', '~> 1.75', '>= 1.75.1'
15
+ gem 'rubocop-capybara', '~> 2.22', '>= 2.22.1'
16
+ gem 'rubocop-performance', '~> 1.24'
17
+ gem 'rubocop-rspec', '~> 3.5'
18
+ gem 'selenium-webdriver', '~> 4.30', '>= 4.30.1'
19
+ gem 'timecop', '~> 0.9.10'
data/Gemfile.lock CHANGED
@@ -1,62 +1,107 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-bootstrap-datepicker (0.2.3)
4
+ capybara-bootstrap-datepicker (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.8.1)
10
- public_suffix (>= 2.0.2, < 6.0)
11
- capybara (3.38.0)
9
+ addressable (2.8.7)
10
+ public_suffix (>= 2.0.2, < 7.0)
11
+ ast (2.4.3)
12
+ base64 (0.2.0)
13
+ capybara (3.40.0)
12
14
  addressable
13
15
  matrix
14
16
  mini_mime (>= 0.1.3)
15
- nokogiri (~> 1.8)
17
+ nokogiri (~> 1.11)
16
18
  rack (>= 1.6.0)
17
19
  rack-test (>= 0.6.3)
18
- regexp_parser (~> 1.5)
20
+ regexp_parser (>= 1.5, < 3.0)
19
21
  xpath (~> 3.2)
20
- capybara-screenshot (1.0.24)
22
+ capybara-screenshot (1.0.26)
21
23
  capybara (>= 1.0, < 4)
22
24
  launchy
23
- cliver (0.3.2)
24
- diff-lcs (1.5.0)
25
- launchy (2.5.2)
25
+ childprocess (5.1.0)
26
+ logger (~> 1.5)
27
+ diff-lcs (1.6.1)
28
+ json (2.10.2)
29
+ language_server-protocol (3.17.0.4)
30
+ launchy (3.1.1)
26
31
  addressable (~> 2.8)
32
+ childprocess (~> 5.0)
33
+ logger (~> 1.6)
34
+ lint_roller (1.1.0)
35
+ logger (1.7.0)
27
36
  matrix (0.4.2)
28
- mini_mime (1.1.2)
29
- mini_portile2 (2.8.1)
30
- nokogiri (1.14.2)
31
- mini_portile2 (~> 2.8.0)
37
+ mini_mime (1.1.5)
38
+ mini_portile2 (2.8.8)
39
+ nokogiri (1.18.6)
40
+ mini_portile2 (~> 2.8.2)
32
41
  racc (~> 1.4)
33
- phantomjs (2.1.1.0)
34
- poltergeist (1.18.1)
35
- capybara (>= 2.1, < 4)
36
- cliver (~> 0.3.1)
37
- websocket-driver (>= 0.2.0)
38
- public_suffix (5.0.1)
39
- racc (1.6.2)
40
- rack (3.0.6.1)
41
- rack-test (2.1.0)
42
+ parallel (1.26.3)
43
+ parser (3.3.7.3)
44
+ ast (~> 2.4.1)
45
+ racc
46
+ prism (1.4.0)
47
+ public_suffix (6.0.1)
48
+ racc (1.8.1)
49
+ rack (3.1.12)
50
+ rack-test (2.2.0)
42
51
  rack (>= 1.3)
43
- regexp_parser (2.7.0)
44
- rspec (3.12.0)
45
- rspec-core (~> 3.12.0)
46
- rspec-expectations (~> 3.12.0)
47
- rspec-mocks (~> 3.12.0)
48
- rspec-core (3.12.1)
49
- rspec-support (~> 3.12.0)
50
- rspec-expectations (3.12.2)
52
+ rainbow (3.1.1)
53
+ regexp_parser (2.10.0)
54
+ rexml (3.4.1)
55
+ rspec (3.13.0)
56
+ rspec-core (~> 3.13.0)
57
+ rspec-expectations (~> 3.13.0)
58
+ rspec-mocks (~> 3.13.0)
59
+ rspec-core (3.13.3)
60
+ rspec-support (~> 3.13.0)
61
+ rspec-expectations (3.13.3)
51
62
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.12.0)
53
- rspec-mocks (3.12.4)
63
+ rspec-support (~> 3.13.0)
64
+ rspec-mocks (3.13.2)
54
65
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.12.0)
56
- rspec-support (3.12.0)
57
- websocket-driver (0.7.1)
58
- websocket-extensions (>= 0.1.0)
59
- websocket-extensions (0.1.5)
66
+ rspec-support (~> 3.13.0)
67
+ rspec-support (3.13.2)
68
+ rubocop (1.75.1)
69
+ json (~> 2.3)
70
+ language_server-protocol (~> 3.17.0.2)
71
+ lint_roller (~> 1.1.0)
72
+ parallel (~> 1.10)
73
+ parser (>= 3.3.0.2)
74
+ rainbow (>= 2.2.2, < 4.0)
75
+ regexp_parser (>= 2.9.3, < 3.0)
76
+ rubocop-ast (>= 1.43.0, < 2.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (>= 2.4.0, < 4.0)
79
+ rubocop-ast (1.43.0)
80
+ parser (>= 3.3.7.2)
81
+ prism (~> 1.4)
82
+ rubocop-capybara (2.22.1)
83
+ lint_roller (~> 1.1)
84
+ rubocop (~> 1.72, >= 1.72.1)
85
+ rubocop-performance (1.24.0)
86
+ lint_roller (~> 1.1)
87
+ rubocop (>= 1.72.1, < 2.0)
88
+ rubocop-ast (>= 1.38.0, < 2.0)
89
+ rubocop-rspec (3.5.0)
90
+ lint_roller (~> 1.1)
91
+ rubocop (~> 1.72, >= 1.72.1)
92
+ ruby-progressbar (1.13.0)
93
+ rubyzip (2.4.1)
94
+ selenium-webdriver (4.30.1)
95
+ base64 (~> 0.2)
96
+ logger (~> 1.4)
97
+ rexml (~> 3.2, >= 3.2.5)
98
+ rubyzip (>= 1.2.2, < 3.0)
99
+ websocket (~> 1.0)
100
+ timecop (0.9.10)
101
+ unicode-display_width (3.1.4)
102
+ unicode-emoji (~> 4.0, >= 4.0.4)
103
+ unicode-emoji (4.0.4)
104
+ websocket (1.2.11)
60
105
  xpath (3.2.0)
61
106
  nokogiri (~> 1.8)
62
107
 
@@ -64,14 +109,19 @@ PLATFORMS
64
109
  ruby
65
110
 
66
111
  DEPENDENCIES
112
+ base64 (~> 0.2.0)
67
113
  capybara (~> 3.29, >= 3.29.0)
68
114
  capybara-bootstrap-datepicker!
69
115
  capybara-screenshot (~> 1.0, >= 1.0.22)
70
- nokogiri (>= 1.6.7.2)
71
- phantomjs (~> 2.1, >= 2.1.1.0)
72
- poltergeist (~> 1.18, >= 1.18.1)
73
- rack (>= 1.6.11)
116
+ nokogiri (~> 1.18, >= 1.18.6)
117
+ rack (~> 3.1, >= 3.1.12)
74
118
  rspec (~> 3.9, >= 3.9.0)
119
+ rubocop (~> 1.75, >= 1.75.1)
120
+ rubocop-capybara (~> 2.22, >= 2.22.1)
121
+ rubocop-performance (~> 1.24)
122
+ rubocop-rspec (~> 3.5)
123
+ selenium-webdriver (~> 4.30, >= 4.30.1)
124
+ timecop (~> 0.9.10)
75
125
 
76
126
  BUNDLED WITH
77
127
  2.3.3
data/README.md CHANGED
@@ -17,6 +17,7 @@ date picker to select the date you want.
17
17
 
18
18
  This gem has been tested with:
19
19
 
20
+ - [Bootstrap] 5.3.3 + [bootstrap-datepicker] 1.10.0 + [jQuery] 3.7.1
20
21
  - [Bootstrap] 5.0.1 + [bootstrap-datepicker] 1.9.0 + [jQuery] 3.6.0
21
22
  - [Bootstrap] 4.4.1 + [bootstrap-datepicker] 1.9.0 + [jQuery] 3.4.1
22
23
  - [Bootstrap] 3.4.1 + [bootstrap-datepicker] 1.9.0 + [jQuery] 3.4.1
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
@@ -18,14 +18,9 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.files = `git ls-files`.split($RS)
20
20
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
21
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
21
  gem.require_paths = ['lib']
23
22
 
24
- gem.required_ruby_version = '>= 2.5.7'
23
+ gem.required_ruby_version = '>= 3.2.8'
25
24
 
26
- gem.add_development_dependency 'capybara', '~> 3.29', '>= 3.29.0'
27
- gem.add_development_dependency 'capybara-screenshot', '~> 1.0', '>= 1.0.22'
28
- gem.add_development_dependency 'phantomjs', '~> 2.1', '>= 2.1.1.0'
29
- gem.add_development_dependency 'poltergeist', '~> 1.18', '>= 1.18.1'
30
- gem.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
25
+ gem.metadata['rubygems_mfa_required'] = 'true'
31
26
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require '../capybara-bootstrap-datepicker'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'capybara-bootstrap-datepicker'
2
4
 
3
5
  RSpec.configure do |c|
@@ -4,6 +4,6 @@
4
4
  module Capybara
5
5
  module BootstrapDatepicker
6
6
  # the current version of the gem
7
- VERSION = '0.2.4'
7
+ VERSION = '1.0.0'
8
8
  end
9
9
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'capybara-bootstrap-datepicker/version'
2
4
 
3
5
  module Capybara
@@ -11,26 +13,25 @@ module Capybara
11
13
  # @param xpath [String, nil] the xpath to input field (required if `from` is nil)
12
14
  # @param args [Hash] extra args to find the input field
13
15
  def select_date(value, datepicker: :bootstrap, format: nil, from: nil, xpath: nil, **args)
14
- fail "Must pass a hash containing 'from' or 'xpath'" if from.nil? && xpath.nil?
16
+ raise "Must pass a hash containing 'from' or 'xpath'" if from.nil? && xpath.nil?
15
17
 
16
18
  value = value.respond_to?(:to_date) ? value.to_date : Date.parse(value)
17
19
  date_input = xpath ? find(:xpath, xpath, **args) : find_field(from, **args)
18
20
 
19
21
  case datepicker
20
22
  when :bootstrap
21
- select_bootstrap_date date_input, value
23
+ select_bootstrap_date(date_input, value:, format:)
22
24
  else
23
- select_simple_date date_input, value, format
25
+ select_simple_date(date_input, value:, format:)
26
+ first(:xpath, '//body').click
24
27
  end
25
-
26
- first(:xpath, '//body').click
27
28
  end
28
29
 
29
30
  # Selects a date by filling the input field
30
31
  # @param date_input the input field
31
32
  # @param value [Date] the date to set
32
33
  # @param format [String, nil] a valid date format used to format value
33
- def select_simple_date(date_input, value, format = nil)
34
+ def select_simple_date(date_input, value:, format: nil)
34
35
  value = value.strftime format unless format.nil?
35
36
 
36
37
  date_input.set "#{value}\e"
@@ -38,7 +39,7 @@ module Capybara
38
39
 
39
40
  # Selects a date by simulating human interaction with the datepicker
40
41
  # @param (see #select_simple_date)
41
- def select_bootstrap_date(date_input, value)
42
+ def select_bootstrap_date(date_input, value:, format: nil)
42
43
  date_input.click
43
44
 
44
45
  picker = Picker.new
@@ -48,13 +49,9 @@ module Capybara
48
49
 
49
50
  picker.find_year(value.year).click
50
51
  picker.find_month(value.month).click
51
- picker.find_day(value.day).click
52
-
53
- fail if Date.parse(date_input.value) != value
52
+ picker.find_day(value.day).click if format.nil? || format.include?('%d')
54
53
  end
55
54
 
56
- private
57
-
58
55
  # The Picker class interacts with the datepicker
59
56
  class Picker
60
57
  # Initializes the picker
@@ -94,12 +91,13 @@ module Capybara
94
91
  # @param value [Fixnum] the day of the desired date
95
92
  # @return the DOM element to click on
96
93
  def find_day(value)
97
- day_xpath = <<-eos
94
+ day_xpath = <<-XPATH
98
95
  .//*[contains(concat(' ', @class, ' '), ' day ')
99
96
  and not(contains(concat(' ', @class, ' '), ' old '))
100
97
  and not(contains(concat(' ', @class, ' '), ' new '))
101
98
  and normalize-space(text())='#{value}']
102
- eos
99
+ XPATH
100
+
103
101
  days.find :xpath, day_xpath
104
102
  end
105
103
 
@@ -184,10 +182,13 @@ module Capybara
184
182
  end
185
183
 
186
184
  # Calculates the distance in decades between min and max
185
+ # @param min [Fixnum] a 4 digits year
186
+ # @param max [Fixnum] a 4 digits year
187
187
  # @return [Fixnum] the distance in decades between min and max
188
188
  def gap(min, max)
189
189
  return 0 if min >= max
190
- (max - min) / 10
190
+
191
+ ((max / 10) - (min / 10))
191
192
  end
192
193
 
193
194
  # Go backward to the wanted decade
@@ -37,6 +37,22 @@
37
37
  <input id="registration-period-start-datapicker" class="form-control" type="text" name="cfp[start_date]">
38
38
  </span>
39
39
  </div>
40
+
41
+ <div class="form-group">
42
+ <label for="my-date-input-with-callbacks">Label of date input with dialog callback</label>
43
+ <div class="input-group date my-date-input-with-callbacks">
44
+ <input type="text" class="form-control" id="my-date-input-with-callbacks">
45
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="form-group">
50
+ <label for="my-date-input-yyyy-mm">Label of my date input with YYYY-MM format</label>
51
+ <div class="input-group date my-date-input-yyyy-mm">
52
+ <input type="text" class="form-control" id="my-date-input-yyyy-mm">
53
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
54
+ </div>
55
+ </div>
40
56
  </form>
41
57
  </div>
42
58
  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
@@ -45,7 +61,12 @@
45
61
  <script type="text/javascript">
46
62
  $('.input-group.default-date').datepicker({ format: 'yyyy-mm-dd' });
47
63
  $('.input-group.locale-date').datepicker({ format: 'yyyy-mm-dd', language: 'ja' });
64
+ $('.my-date-input-yyyy-mm').datepicker({ format: 'yyyy-mm', minViewMode: 1 });
48
65
  $('#registration-period-start-datapicker').datepicker({ format: 'yyyy-mm-dd', minDate : '2019-03-06', maxDate : '2019-03-12' });
66
+
67
+ $('.input-group.my-date-input-with-callbacks')
68
+ .datepicker({ format: 'yyyy-mm-dd' })
69
+ .on('change', function() { alert('Date has changed') });
49
70
  </script>
50
71
  </body>
51
72
  </html>
@@ -37,6 +37,22 @@
37
37
  <input id="registration-period-start-datapicker" class="form-control" type="text" name="cfp[start_date]">
38
38
  </span>
39
39
  </div>
40
+
41
+ <div class="form-group">
42
+ <label for="my-date-input-with-callbacks">Label of date input with dialog callback</label>
43
+ <div class="input-group date my-date-input-with-callbacks">
44
+ <input type="text" class="form-control" id="my-date-input-with-callbacks">
45
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="form-group">
50
+ <label for="my-date-input-yyyy-mm">Label of my date input with YYYY-MM format</label>
51
+ <div class="input-group date my-date-input-yyyy-mm">
52
+ <input type="text" class="form-control" id="my-date-input-yyyy-mm">
53
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
54
+ </div>
55
+ </div>
40
56
  </form>
41
57
  </div>
42
58
  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
@@ -45,12 +61,12 @@
45
61
  <script type="text/javascript">
46
62
  $('.input-group.default-date').datepicker({ format: 'yyyy-mm-dd' });
47
63
  $('.input-group.locale-date').datepicker({ format: 'yyyy-mm-dd', language: 'ja' });
48
-
49
- $('#registration-period-start-datapicker').datepicker({
50
- format: 'yyyy-mm-dd',
51
- minDate : '2019-03-06',
52
- maxDate : '2019-03-12'
53
- });
64
+ $('.my-date-input-yyyy-mm').datepicker({ format: 'yyyy-mm', minViewMode: 1 });
65
+ $('#registration-period-start-datapicker').datepicker({ format: 'yyyy-mm-dd', minDate : '2019-03-06', maxDate : '2019-03-12' });
66
+
67
+ $('.input-group.my-date-input-with-callbacks')
68
+ .datepicker({ format: 'yyyy-mm-dd' })
69
+ .on('change', function() { alert('Date has changed') });
54
70
  </script>
55
71
  </body>
56
72
  </html>
@@ -37,6 +37,22 @@
37
37
  <input id="registration-period-start-datapicker" class="form-control" type="text" name="cfp[start_date]">
38
38
  </span>
39
39
  </div>
40
+
41
+ <div class="form-group">
42
+ <label for="my-date-input-with-callbacks">Label of date input with dialog callback</label>
43
+ <div class="input-group date my-date-input-with-callbacks">
44
+ <input type="text" class="form-control" id="my-date-input-with-callbacks">
45
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="form-group">
50
+ <label for="my-date-input-yyyy-mm">Label of my date input with YYYY-MM format</label>
51
+ <div class="input-group date my-date-input-yyyy-mm">
52
+ <input type="text" class="form-control" id="my-date-input-yyyy-mm">
53
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
54
+ </div>
55
+ </div>
40
56
  </form>
41
57
  </div>
42
58
  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
@@ -45,12 +61,12 @@
45
61
  <script type="text/javascript">
46
62
  $('.input-group.default-date').datepicker({ format: 'yyyy-mm-dd' });
47
63
  $('.input-group.locale-date').datepicker({ format: 'yyyy-mm-dd', language: 'ja' });
48
-
49
- $('#registration-period-start-datapicker').datepicker({
50
- format: 'yyyy-mm-dd',
51
- minDate : '2019-03-06',
52
- maxDate : '2019-03-12'
53
- });
64
+ $('.my-date-input-yyyy-mm').datepicker({ format: 'yyyy-mm', minViewMode: 1 });
65
+ $('#registration-period-start-datapicker').datepicker({ format: 'yyyy-mm-dd', minDate : '2019-03-06', maxDate : '2019-03-12' });
66
+
67
+ $('.input-group.my-date-input-with-callbacks')
68
+ .datepicker({ format: 'yyyy-mm-dd' })
69
+ .on('change', function() { alert('Date has changed') });
54
70
  </script>
55
71
  </body>
56
72
  </html>
@@ -0,0 +1,72 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.3/css/bootstrap.min.css">
4
+ <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker3.min.css">
5
+ </head>
6
+ <body>
7
+ <div class="container">
8
+ <h1>Bootstrap 5.3 Datepicker</h1>
9
+
10
+ <form action=".">
11
+ <div class="form-group">
12
+ <label for="my-date-input">Label of my date input</label>
13
+ <div class="input-group date default-date">
14
+ <input type="text" class="form-control" id="my-date-input">
15
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
16
+ </div>
17
+ </div>
18
+
19
+ <div class="form-group">
20
+ <label for="my-localized-date-input">Label of my localized date input</label>
21
+ <div class="input-group date locale-date">
22
+ <input type="text" class="form-control" id="my-localized-date-input">
23
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="required form-group" id="cfp_start_date_input">
28
+ <span class="form-label">
29
+ <label for="registration-period-start-datapicker" class="control-label">
30
+ Start date&nbsp;
31
+ <span class="text-warning">
32
+ <abbr title="This field is required">*</abbr>
33
+ </span>
34
+ </label>
35
+ </span>
36
+ <span class="form-wrapper">
37
+ <input id="registration-period-start-datapicker" class="form-control" type="text" name="cfp[start_date]">
38
+ </span>
39
+ </div>
40
+
41
+ <div class="form-group">
42
+ <label for="my-date-input-with-callbacks">Label of date input with dialog callback</label>
43
+ <div class="input-group date my-date-input-with-callbacks">
44
+ <input type="text" class="form-control" id="my-date-input-with-callbacks">
45
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
46
+ </div>
47
+ </div>
48
+
49
+ <div class="form-group">
50
+ <label for="my-date-input-yyyy-mm">Label of my date input with YYYY-MM format</label>
51
+ <div class="input-group date my-date-input-yyyy-mm">
52
+ <input type="text" class="form-control" id="my-date-input-yyyy-mm">
53
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
54
+ </div>
55
+ </div>
56
+ </form>
57
+ </div>
58
+ <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
59
+ <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.3/js/bootstrap.min.js"></script>
60
+ <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
61
+ <script type="text/javascript">
62
+ $('.input-group.default-date').datepicker({ format: 'yyyy-mm-dd' });
63
+ $('.input-group.locale-date').datepicker({ format: 'yyyy-mm-dd', language: 'ja' });
64
+ $('.my-date-input-yyyy-mm').datepicker({ format: 'yyyy-mm', minViewMode: 1 });
65
+ $('#registration-period-start-datapicker').datepicker({ format: 'yyyy-mm-dd', minDate : '2019-03-06', maxDate : '2019-03-12' });
66
+
67
+ $('.input-group.my-date-input-with-callbacks')
68
+ .datepicker({ format: 'yyyy-mm-dd' })
69
+ .on('change', function() { alert('Date has changed') });
70
+ </script>
71
+ </body>
72
+ </html>
@@ -1,83 +1,164 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'timecop'
4
+
3
5
  RSpec.shared_examples 'a datepicker' do
4
- context 'default date' do
5
- subject { Date.parse(find_field('Label of my date input').value) }
6
+ before do
7
+ Timecop.travel(Time.local(2023, 3, 31))
8
+ end
9
+
10
+ context 'with default date' do
11
+ subject { Date.parse(find_field(label).value) }
6
12
 
7
- it 'fills in an input without using the datepicker', js: true do
8
- select_date Date.today, from: 'Label of my date input'
13
+ let(:label) { 'Label of my date input' }
14
+
15
+ it 'fills in an input without using the datepicker', :js do
16
+ select_date Date.today, from: label
9
17
  expect(subject).to eq Date.today
10
18
  end
11
19
 
12
- it 'fills in a standard datepicker', js: true do
13
- select_date Date.today, from: 'Label of my date input', datepicker: :simple
20
+ it 'fills in a standard datepicker', :js do
21
+ select_date Date.today, from: label, datepicker: :simple
14
22
  expect(subject).to eq Date.today
15
23
  end
16
24
 
17
- it 'fills in a datepicker based on Bootstrap', js: true do
18
- select_date Date.today, from: 'Label of my date input', datepicker: :bootstrap
25
+ it 'fills in a datepicker based on Bootstrap', :js do
26
+ select_date Date.today, from: label, datepicker: :bootstrap
19
27
  expect(subject).to eq Date.today
20
28
  end
21
29
 
22
- it 'fills in an input with DateTime object', js: true do
23
- select_date DateTime.now, from: 'Label of my date input'
30
+ it 'fills in an input with DateTime object', :js do
31
+ select_date DateTime.now, from: label
24
32
  expect(subject).to eq Date.today
25
33
  end
26
34
  end
27
35
 
28
- context 'locale date' do
29
- subject { Date.parse(find_field('Label of my localized date input').value) }
36
+ context 'when decade discovery' do
37
+ subject { Date.parse(find_field(label).value) }
30
38
 
31
- it 'fills in a localized datepicker based on Bootstrap', js: true do
32
- select_date Date.today, from: 'Label of my localized date input', datepicker: :bootstrap
33
- expect(subject).to eq Date.today
39
+ let(:label) { 'Label of my date input' }
40
+
41
+ it 'fills in date in previous decade', :js do
42
+ date = Date.new(2018)
43
+
44
+ select_date date, from: label
45
+ expect(subject).to eq date
34
46
  end
35
- end
36
47
 
37
- context 'required date' do
38
- subject { Date.parse(find_field('Start date').value) }
48
+ it 'fills in date in current decade', :js do
49
+ date = Date.new(2021)
39
50
 
40
- it 'fills in a required datepicker based on Bootstrap', js: true do
41
- select_date Date.today, from: 'Start date', datepicker: :bootstrap
42
- expect(subject).to eq Date.today
51
+ select_date date, from: label
52
+ expect(subject).to eq date
43
53
  end
44
- end
45
- end
46
54
 
47
- RSpec.describe 'Bootstrap Datepicker', type: :feature do
48
- describe 'Boostrap 3.4' do
49
- before :each do
50
- Capybara.current_session.driver.visit "#{Capybara.app_host}/bootstrap-3.4.html"
55
+ it 'fills in date in next decade', :js do
56
+ date = Date.new(2032)
57
+
58
+ select_date date, from: label
59
+ expect(subject).to eq date
51
60
  end
52
61
 
53
- it 'loads the page correctly', js: true do
54
- expect(page).to have_content 'Bootstrap 3.4 Datepicker'
62
+ it 'fills in date 3 decades in the past', :js do
63
+ date = Date.new(1998)
64
+
65
+ select_date date, from: label
66
+ expect(subject).to eq date
55
67
  end
56
68
 
57
- it_behaves_like 'a datepicker'
69
+ it 'fills in date 3 decades in the future', :js do
70
+ date = Date.new(2052)
71
+
72
+ select_date date, from: label
73
+ expect(subject).to eq date
74
+ end
58
75
  end
59
76
 
60
- describe 'Boostrap 4.4' do
61
- before :each do
62
- Capybara.current_session.driver.visit "#{Capybara.app_host}/bootstrap-4.4.html"
77
+ context 'with dialog callback' do
78
+ subject { Date.parse(find_field(label).value) }
79
+
80
+ let(:label) { 'with dialog callback' }
81
+
82
+ it 'fills in a datepicker while passing alert dialog', :js do
83
+ accept_alert 'Date has changed' do
84
+ select_date Date.today, from: label, datepicker: :simple
85
+ end
86
+
87
+ expect(subject).to eq Date.today
63
88
  end
64
89
 
65
- it 'loads the page correctly', js: true do
66
- expect(page).to have_content 'Bootstrap 4.4 Datepicker'
90
+ it 'fills in a datepicker while passing alert dialog on Bootstrap', :js do
91
+ accept_alert 'Date has changed' do
92
+ select_date Date.today, from: label, datepicker: :bootstrap
93
+ end
94
+
95
+ expect(subject).to eq Date.today
67
96
  end
97
+ end
98
+
99
+ context 'with locale date' do
100
+ subject { Date.parse(find_field('localized date input').value) }
101
+
102
+ let(:label) { 'localized date input' }
68
103
 
69
- it_behaves_like 'a datepicker'
104
+ it 'fills in a localized datepicker based on Bootstrap', :js do
105
+ select_date Date.today, from: label, datepicker: :bootstrap
106
+ expect(subject).to eq Date.today
107
+ end
70
108
  end
71
109
 
72
- describe 'Boostrap 5.0' do
73
- before :each do
74
- Capybara.current_session.driver.visit "#{Capybara.app_host}/bootstrap-5.0.html"
110
+ context 'with required date' do
111
+ subject { Date.parse(find_field(label).value) }
112
+
113
+ let(:label) { 'Start date' }
114
+
115
+ it 'fills in a required datepicker based on Bootstrap', :js do
116
+ select_date Date.today, from: label, datepicker: :bootstrap
117
+ expect(subject).to eq Date.today
75
118
  end
119
+ end
120
+
121
+ context 'with yyyy-mm format' do
122
+ subject { Date.strptime(find_field(label).value, '%Y-%m') }
123
+
124
+ let(:label) { 'with YYYY-MM format' }
76
125
 
77
- it 'loads the page correctly', js: true do
78
- expect(page).to have_content 'Bootstrap 5.0 Datepicker'
126
+ it 'fills in a date without day', :js do
127
+ select_date Date.today, from: label, datepicker: :simple, format: '%Y-%m'
128
+ expect(subject).to eq Date.new(2023, 3)
79
129
  end
80
130
 
81
- it_behaves_like 'a datepicker'
131
+ it 'fills in a date without day on Bootstrap', :js do
132
+ select_date Date.today, from: label, datepicker: :bootstrap, format: '%Y-%m'
133
+ expect(subject).to eq Date.new(2023, 3)
134
+ end
135
+ end
136
+ end
137
+
138
+ RSpec.describe 'Bootstrap Datepicker', type: :feature do
139
+ browsers = %i[firefox chrome]
140
+ bootstrap_versions = ['3.4', '4.4', '5.0', '5.3']
141
+
142
+ browsers.each do |browser|
143
+ describe "Driven by #{browser}" do
144
+ before do
145
+ Capybara.current_driver = browser
146
+ Capybara.javascript_driver = browser
147
+ end
148
+
149
+ bootstrap_versions.each do |version|
150
+ describe "Boostrap #{version}" do
151
+ before do
152
+ Capybara.current_session.driver.visit "#{Capybara.app_host}/bootstrap-#{version}.html"
153
+ end
154
+
155
+ it 'loads the page correctly', :js do
156
+ expect(page).to have_content "Bootstrap #{version} Datepicker"
157
+ end
158
+
159
+ it_behaves_like 'a datepicker'
160
+ end
161
+ end
162
+ end
82
163
  end
83
164
  end
data/spec/spec_helper.rb CHANGED
@@ -1,21 +1,34 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2
4
  require 'bundler/setup'
3
5
  Bundler.setup
4
6
 
5
- require 'capybara-bootstrap-datepicker/rspec'
6
7
  require 'capybara'
7
8
  require 'capybara/rspec'
9
+ require 'capybara-bootstrap-datepicker/rspec'
8
10
  require 'capybara-screenshot/rspec'
9
- require 'capybara/poltergeist'
10
- require 'phantomjs/poltergeist'
11
+ require 'selenium-webdriver'
11
12
 
12
13
  Capybara.configure do |config|
13
- config.javascript_driver = :poltergeist
14
14
  config.app_host = "file://#{File.expand_path('features', __dir__)}"
15
15
  end
16
16
 
17
- Capybara.register_driver :poltergeist do |app|
18
- Capybara::Poltergeist::Driver.new app, phantomjs: Phantomjs.path, window_size: [1280, 1024], inspector: true, js_errors: false, timeout: 45
17
+ Capybara.register_driver :chrome do |app|
18
+ options = Selenium::WebDriver::Chrome::Options.new
19
+ options.add_argument('headless')
20
+ options.add_argument('disable-gpu')
21
+ options.add_argument('--disable-translate')
22
+ options.add_argument('--window-size=1200,2000')
23
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
24
+ end
25
+
26
+ Capybara.register_driver :firefox do |app|
27
+ options = Selenium::WebDriver::Firefox::Options.new
28
+ options.add_argument('--headless')
29
+ options.browser_version = 'esr'
30
+
31
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
19
32
  end
20
33
 
21
34
  RSpec.configure do |config|
metadata CHANGED
@@ -1,115 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-bootstrap-datepicker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - François Vantomme
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: capybara
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.29'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 3.29.0
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.29'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 3.29.0
33
- - !ruby/object:Gem::Dependency
34
- name: capybara-screenshot
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.0'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.0.22
43
- type: :development
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.0'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.0.22
53
- - !ruby/object:Gem::Dependency
54
- name: phantomjs
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '2.1'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 2.1.1.0
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '2.1'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 2.1.1.0
73
- - !ruby/object:Gem::Dependency
74
- name: poltergeist
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '1.18'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.18.1
83
- type: :development
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.18'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 1.18.1
93
- - !ruby/object:Gem::Dependency
94
- name: rspec
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '3.9'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 3.9.0
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.9'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 3.9.0
10
+ date: 2025-04-04 00:00:00.000000000 Z
11
+ dependencies: []
113
12
  description: Helper for triggering date input for bootstrap-datepicker javascript
114
13
  library
115
14
  email:
@@ -120,6 +19,8 @@ extra_rdoc_files: []
120
19
  files:
121
20
  - ".gitignore"
122
21
  - ".rspec"
22
+ - ".rubocop.yml"
23
+ - ".rubocop_todo.yml"
123
24
  - ".ruby-version"
124
25
  - ".travis.yml"
125
26
  - Gemfile
@@ -135,13 +36,14 @@ files:
135
36
  - spec/features/bootstrap-3.4.html
136
37
  - spec/features/bootstrap-4.4.html
137
38
  - spec/features/bootstrap-5.0.html
39
+ - spec/features/bootstrap-5.3.html
138
40
  - spec/features/bootstrap_datepicker_spec.rb
139
41
  - spec/spec_helper.rb
140
42
  homepage: https://github.com/akarzim/capybara-bootstrap-datepicker
141
43
  licenses:
142
44
  - MIT
143
- metadata: {}
144
- post_install_message:
45
+ metadata:
46
+ rubygems_mfa_required: 'true'
145
47
  rdoc_options: []
146
48
  require_paths:
147
49
  - lib
@@ -149,20 +51,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
51
  requirements:
150
52
  - - ">="
151
53
  - !ruby/object:Gem::Version
152
- version: 2.5.7
54
+ version: 3.2.8
153
55
  required_rubygems_version: !ruby/object:Gem::Requirement
154
56
  requirements:
155
57
  - - ">="
156
58
  - !ruby/object:Gem::Version
157
59
  version: '0'
158
60
  requirements: []
159
- rubygems_version: 3.3.3
160
- signing_key:
61
+ rubygems_version: 3.6.2
161
62
  specification_version: 4
162
63
  summary: Bootstrap datepicker helper for Capybara
163
- test_files:
164
- - spec/features/bootstrap-3.4.html
165
- - spec/features/bootstrap-4.4.html
166
- - spec/features/bootstrap-5.0.html
167
- - spec/features/bootstrap_datepicker_spec.rb
168
- - spec/spec_helper.rb
64
+ test_files: []