Sha256: 23a77744e60245e548e52c9ba25dfd18b5cac2c79105a73cdd6731e48144d590

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

require 'active_support/core_ext/array/extract_options'

module Bbq
  module Core
    class TestUser
      module Within
        METHODS_USING_WITHIN = [
          :see?, :not_see?,
          :attach_file, :check, :choose, :click_link_or_button, :click_button,
          :click_link, :click_on, :fill_in, :select, :uncheck, :unselect
        ]

        METHODS_USING_WITHIN.each do |method_name|
          class_eval <<-RUBY
            def #{method_name}(*args)
              using_within(args) { super }
            end
          RUBY
        end

        def using_within(args)
          options = args.extract_options!
          locator = options.delete(:within)
          args.push(options) unless options.empty?

          if locator
            within(locator) { yield }
          else
            yield
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bbq-core-0.4.0 lib/bbq/core/test_user/within.rb
bbq-core-0.3.0 lib/bbq/core/test_user/within.rb