mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
Capybara now works 🎉
This commit is contained in:
26
spec/support/capybara.rb
Normal file
26
spec/support/capybara.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# Setup chrome headless driver
|
||||
Capybara.server = :puma, { Silent: true }
|
||||
|
||||
Capybara.register_driver :chrome_headless do |app|
|
||||
options = ::Selenium::WebDriver::Chrome::Options.new
|
||||
|
||||
options.add_argument('--headless')
|
||||
options.add_argument('--no-sandbox')
|
||||
options.add_argument('--disable-dev-shm-usage')
|
||||
options.add_argument('--window-size=1400,1400')
|
||||
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
||||
end
|
||||
|
||||
Capybara.javascript_driver = :chrome_headless
|
||||
|
||||
# Setup rspec
|
||||
RSpec.configure do |config|
|
||||
config.before(:each, type: :system) do
|
||||
driven_by :rack_test
|
||||
end
|
||||
|
||||
config.before(:each, type: :system, js: true) do
|
||||
driven_by :chrome_headless
|
||||
end
|
||||
end
|
||||
@@ -1,20 +1,31 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# RSpec.describe "Session", type: :system do
|
||||
RSpec.describe 'Session', type: :system do
|
||||
|
||||
# def log_in_as(user)
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
before(:each) { user.confirm } # devise helper to confirm user email
|
||||
|
||||
it 'allows guests to sign in' do
|
||||
user_count = User.count
|
||||
|
||||
visit new_user_registration_path
|
||||
fill_in 'Full name', with: 'Test Test'
|
||||
fill_in 'Email', with: 'test@test.com'
|
||||
fill_in 'Password', with: 'password'
|
||||
fill_in 'Password confirmation', with: 'password'
|
||||
click_button 'Sign up'
|
||||
|
||||
expect(User.count).to eq(user_count + 1)
|
||||
end
|
||||
|
||||
# it 'allows users to log in' do
|
||||
# visit new_user_session_path
|
||||
# fill_in "Email", with: "user0@example.com"
|
||||
# fill_in "Password", with: "password"
|
||||
# fill_in "Email", with: user.email
|
||||
# fill_in "Password", with: user.password
|
||||
# click_button "Log in"
|
||||
|
||||
# expect(current_path).to eq(root_path)
|
||||
# end
|
||||
|
||||
# let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
# it 'allows a logged-in user to view profile settings' do
|
||||
# log_in_as user
|
||||
# visit edit_user_registration_path
|
||||
# expect(current_path).to eq(edit_user_registration_path)
|
||||
# end
|
||||
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user