Sha256: 2cf8d0842ecf2bd09f2857b04a30a0da7afc029f9ab34065a8f5cf16093539e0

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

require 'test_helper'
require 'capybara/rails'

class ActionDispatch::IntegrationTest
  include Capybara::DSL
  self.fixture_path = File.expand_path('../fixtures', __FILE__)

  def login(user)
    visit login_path
    fill_in 'Username', with: user.username
    fill_in 'Password', with: user.password
    click_button 'Login'
    assert current_path == landing_path
    assert page.has_content? 'You have been logged in.'
  end

  def logout
    visit logout_path
    assert current_path == login_path
    assert page.has_content? 'You have been logged out.'
  end
end

# Prevent database locks when testing AJAX features
# https://github.com/jnicklas/capybara#transactions-and-database-setup
class ActiveRecord::Base
  mattr_accessor :shared_connection
  @@shared_connection = nil

  def self.connection
    @@shared_connection || retrieve_connection
  end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dismissible_blocks-1.1.1 test/capybara_helper.rb
dismissible_blocks-1.1.0 test/capybara_helper.rb