Skip to content

Instantly share code, notes, and snippets.

@ssaadh
Created March 6, 2013 22:17
Show Gist options
  • Save ssaadh/5103612 to your computer and use it in GitHub Desktop.
Save ssaadh/5103612 to your computer and use it in GitHub Desktop.
Using the capybara DSL elsewhere - You can mix the DSL into any context by including Capybara::DSL. - This enables its use in unsupported testing frameworks, and for general-purpose scripting.
# You can mix the DSL into any context by including Capybara::DSL
# This enables its use in unsupported testing frameworks, and for general-purpose scripting
require 'capybara'
require 'capybara/dsl'
Capybara.default_driver = :webkit
module MyModule
include Capybara::DSL
def login!
within("//form[@id='session']") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment