#in Gemfile group :development, :test add
bundle add rspec-rails
rails generate rspec:install
uncomment
config.filter_run_when_matching :focus
https://github.com/thoughtbot/factory_bot_rails
#in Gemfile group :development, :test add
gem "factory_bot_rails"
https://github.com/teamcapybara/capybara
#in Gemfile group :test add
gem "capybara"
gem "launchy" # for capybara save_and_open_page
gem "webdrivers"
touch spec/capybara_helper.rb
# frozen_string_literal: true
require "rails_helper"
require "capybara/rspec"
RSpec.configure do |config|
config.include Capybara::RSpecMatchers
Capybara.default_max_wait_time = 10 # The maximum number of seconds to wait for asynchronous processes to finish.
Capybara.default_normalize_ws = true # match DOM Elements with text spanning over multiple line
config.before(:each, type: :system) do
driven_by :rack_test
end
config.before(:each, type: :system, js: true) do
# https://api.rubyonrails.org/v6.0.1/classes/ActionDispatch/SystemTestCase.html#method-c-driven_by
browser = ENV["SELENIUM_BROWSER"].presence&.to_sym || :headless_chrome
driven_by :selenium, using: browser, screen_size: [1600, 1400]
end
end
mkdir -p spec/system/
touch spec/system/welcome_spec.rb
require "capybara_helper"
describe "welcome", type: :system do
it "shows the tranding tracks of this year" do
visit "/"
expect(page).to have_content("Welcome")
end
end