1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/dsl.rb
Jo Liss 76f4df28dc Move methods on top-level Capybara module from dsl.rb to capybara.rb
Do not require "capybara/dsl" in capybara.rb (reverting 1192ea34),
because it crashes from load-ordering issues. However, we now autoload
Capybara::DSL.
2011-12-30 17:54:44 +01:00

50 lines
953 B
Ruby

require 'capybara'
module Capybara
module DSL
##
#
# 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|
class_eval <<-RUBY, __FILE__, __LINE__+1
def #{method}(*args, &block)
page.#{method}(*args, &block)
end
RUBY
end
end
extend(Capybara::DSL)
end