Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gaming_test.rb
# 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 => 'player@example.com'
# 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 => 'player@example.com'
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
You can’t perform that action at this time.