Sha256: 765475fd3e079c3c0cf08a767911078ffcc014877a4f369c8f3d62f0c24c2a5a

Contents?: true

Size: 900 Bytes

Versions: 1

Compression:

Stored size: 900 Bytes

Contents

require "tedium/virtual_date_element"

module Tedium
  module SitePrism
    module FormDsl
      def field(name, attribute_name = name)
        element "#{name}_field", :input_for_field, attribute_name
      end

      def fields(*names)
        names.each { |n| field n }
      end

      def date_field(name, attribute_name = name)
        define_method "#{name}_field" do
          VirtualDateElement.new(root_element_or_page, attribute_name)
        end
      end

      def submit_button(role = nil)
        element :submit_button, :submit_button, role

        define_method :submit! do
          submit_button.click
        end
      end

      def submission(name, fields)
        define_method "#{name}!" do |*args|
          Array(fields).each_with_index do |field, i|
            send("#{field}_field").set(args[i])
          end
          submit!
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tedium-0.0.1 lib/tedium/site_prism/form_dsl.rb