-
-
Save psahni/882715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of how you can to use Capybara with plain Rails' integration tests and FactoryGirl (or plain MyModel.create…) | |
require 'test_helper' | |
require 'capybara' | |
require 'capybara/dsl' | |
require 'database_cleaner' | |
Capybara.app = Pardy::Application | |
Capybara.default_driver = :rack_test | |
DatabaseCleaner.strategy = :truncation | |
class GamingTest < ActionDispatch::IntegrationTest | |
include Capybara | |
# use_transactional_fixtures = false # DOES NOT WORK! | |
self.use_transactional_fixtures = false # DOES WORK! Damn it! | |
# … think this should be renamed and should definitely get some documentation love. | |
setup do | |
DatabaseCleaner.start | |
assert User.create! :name => 'player', :password => 'password', :password_confirmation => 'password', :email => '[email protected]' | |
# or Factory(:user....) | |
end | |
teardown do | |
DatabaseCleaner.clean | |
end | |
test "login player" do | |
Capybara.current_driver = :selenium | |
visit login_path | |
fill_in 'user_email', :with => '[email protected]' | |
fill_in 'user_password', :with => 'password' | |
click_button 'Sign in' | |
assert { current_path == root_path } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment