Sha256: 3a2fced7e66b003b7f9ec839a87372b23f2b57f2f82f0b30b2aca7cccd96119e

Contents?: true

Size: 1.22 KB

Versions: 40

Compression:

Stored size: 1.22 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_or_session, &block)
      Capybara.using_session(name_or_session, &block)
    end

    # Shortcut to using a different wait time.
    #
    def using_wait_time(seconds, &block)
      page.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

40 entries across 40 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/dsl.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/dsl.rb
capybara-3.30.0 lib/capybara/dsl.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/dsl.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/dsl.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/dsl.rb
capybara-3.29.0 lib/capybara/dsl.rb
capybara-3.28.0 lib/capybara/dsl.rb
capybara-3.27.0 lib/capybara/dsl.rb
capybara-3.26.0 lib/capybara/dsl.rb
capybara-3.25.0 lib/capybara/dsl.rb
capybara-3.24.0 lib/capybara/dsl.rb
capybara-3.23.0 lib/capybara/dsl.rb
capybara-3.22.0 lib/capybara/dsl.rb
capybara-3.21.0 lib/capybara/dsl.rb
capybara-3.20.2 lib/capybara/dsl.rb
capybara-3.20.1 lib/capybara/dsl.rb
capybara-3.20.0 lib/capybara/dsl.rb
capybara-3.19.1 lib/capybara/dsl.rb
capybara-3.19.0 lib/capybara/dsl.rb