Module: Capybara::DSL

Included in:
Capybara
Defined in:
lib/capybara/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



11
12
13
14
# File 'lib/capybara/dsl.rb', line 11

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

.included(base) ⇒ Object



6
7
8
9
# File 'lib/capybara/dsl.rb', line 6

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

Instance Method Details

#pageCapybara::Session

Shortcut to accessing the current session.

class MyClass
  include Capybara::DSL

  def has_header?
    page.has_css?('h1')
  end
end

Returns:



46
47
48
# File 'lib/capybara/dsl.rb', line 46

def page
  Capybara.current_session
end

#using_session(name, &block) ⇒ Object

Shortcut to working in a different session.



20
21
22
# File 'lib/capybara/dsl.rb', line 20

def using_session(name, &block)
  Capybara.using_session(name, &block)
end

#using_wait_time(seconds, &block) ⇒ Object

Shortcut to using a different wait time.



28
29
30
# File 'lib/capybara/dsl.rb', line 28

def using_wait_time(seconds, &block)
  Capybara.using_wait_time(seconds, &block)
end