Sha256: 1a82230f9c0770fcb2052771465958f638b657d9056e69aa994040464f287db9

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true
require 'capybara'

module Capybara
  module DSL
    def self.included(base)
      warn "including Capybara::DSL in the global scope is not recommended!" if base == Object
      super
    end

    def self.extended(base)
      warn "extending the main object with Capybara::DSL is not recommended!" if base == TOPLEVEL_BINDING.eval("self")
      super
    end

    ##
    #
    # Shortcut to working in a different session.
    #
    def using_session(name, &block)
      Capybara.using_session(name, &block)
    end

    ##
    #
    # Shortcut to using a different wait time.
    #
    def using_wait_time(seconds, &block)
      Capybara.using_wait_time(seconds, &block)
    end

    ##
    #
    # Shortcut to accessing the current session.
    #
    #     class MyClass
    #       include Capybara::DSL
    #
    #       def has_header?
    #         page.has_css?('h1')
    #       end
    #     end
    #
    # @return [Capybara::Session] The current session object
    #
    def page
      Capybara.current_session
    end

    Session::DSL_METHODS.each do |method|
      define_method method do |*args, &block|
        page.send method, *args, &block
      end
    end
  end

  extend(Capybara::DSL)
end

Version data entries

20 entries across 19 versions & 3 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/capybara-2.13.0/lib/capybara/dsl.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/capybara-2.13.0/lib/capybara/dsl.rb
tdiary-5.0.4 vendor/bundle/gems/capybara-2.13.0/lib/capybara/dsl.rb
capybara-2.13.0 lib/capybara/dsl.rb
capybara-2.12.1 lib/capybara/dsl.rb
capybara-2.12.0 lib/capybara/dsl.rb
capybara-2.11.0 lib/capybara/dsl.rb
capybara-2.10.2 lib/capybara/dsl.rb
capybara-2.10.1 lib/capybara/dsl.rb
capybara-2.10.0 lib/capybara/dsl.rb
capybara-2.9.2 lib/capybara/dsl.rb
tdiary-5.0.2 vendor/bundle/gems/capybara-2.8.0/lib/capybara/dsl.rb
capybara-2.9.1 lib/capybara/dsl.rb
capybara-2.9.0 lib/capybara/dsl.rb
capybara-2.8.1 lib/capybara/dsl.rb
capybara-2.8.0 lib/capybara/dsl.rb
tdiary-5.0.1 vendor/bundle/gems/capybara-2.7.1/lib/capybara/dsl.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb
capybara-2.7.1 lib/capybara/dsl.rb
capybara-2.7.0 lib/capybara/dsl.rb