Sha256: cc087fbc4432b10af6252799ee24e239378b5491fdbb830b187e60140da8966d

Contents?: true

Size: 856 Bytes

Versions: 6

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module DatepickerDateFill
    # fill datepicker field correctly

    def fill_in_datepicker(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
      find_options[:with] = currently_with if currently_with
      find_options[:allow_self] = true if locator.nil?
      with.chars.each do |character|
        if character == "/"
          find(:fillable_field, locator, **find_options).send_keys(:divide, **fill_options)
        elsif character == "."
          find(:fillable_field, locator, **find_options).send_keys(:decimal, **fill_options)
        else
          find(:fillable_field, locator, **find_options).send_keys(character, **fill_options)
        end
      end
    end
  end
end

RSpec.configure do |config|
  config.include Capybara::DatepickerDateFill, type: :system
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-dev-0.29.1 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb
decidim-dev-0.29.0 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb
decidim-dev-0.29.0.rc4 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb
decidim-dev-0.29.0.rc3 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb
decidim-dev-0.29.0.rc2 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb
decidim-dev-0.29.0.rc1 lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb