├── .github ├── FUNDING.yml └── workflows │ └── ruby.yml ├── .gitignore ├── .rspec ├── CHANGELOG.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── cypress-on-rails.gemspec ├── docs ├── authentication.md └── factory_bot_associations.md ├── lib ├── cypress-on-rails.rb ├── cypress │ └── smart_factory_wrapper.rb ├── cypress_dev.rb ├── cypress_dev │ ├── middleware.rb │ └── smart_factory_wrapper.rb ├── cypress_on_rails │ ├── command_executor.rb │ ├── configuration.rb │ ├── middleware.rb │ ├── middleware_config.rb │ ├── railtie.rb │ ├── simple_rails_factory.rb │ ├── smart_factory_wrapper.rb │ ├── vcr_middleware.rb │ └── version.rb └── generators │ └── cypress_on_rails │ ├── install_generator.rb │ └── templates │ ├── config │ └── initializers │ │ └── cypress_on_rails.rb.erb │ └── spec │ ├── cypress.config.js │ ├── cypress │ ├── e2e │ │ └── rails_examples │ │ │ ├── advance_factory_bot.cy.js │ │ │ ├── other.cy.js │ │ │ ├── using_factory_bot.cy.js │ │ │ ├── using_fixtures.cy.js │ │ │ ├── using_scenarios.cy.js │ │ │ └── using_vcr.cy.js │ └── support │ │ ├── commands.js │ │ ├── index.js.erb │ │ └── on-rails.js │ ├── e2e │ ├── app_commands │ │ ├── activerecord_fixtures.rb │ │ ├── clean.rb │ │ ├── eval.rb │ │ ├── factory_bot.rb │ │ ├── log_fail.rb │ │ └── scenarios │ │ │ └── basic.rb │ └── e2e_helper.rb.erb │ ├── playwright.config.js │ └── playwright │ ├── e2e │ └── rails_examples │ │ └── using_scenarios.spec.js │ └── support │ ├── index.js.erb │ └── on-rails.js ├── plugin ├── .gitignore ├── cypress │ └── plugins │ │ └── index.js ├── package.json └── support │ └── index.js ├── spec ├── cypress_on_rails │ ├── command_executor │ │ ├── e2e_helper.rb │ │ ├── test_command.rb │ │ └── test_command_with_options.rb │ ├── command_executor_spec.rb │ ├── configuration_spec.rb │ ├── middleware_spec.rb │ ├── railtie_spec.rb │ ├── simple_rails_factory_spec.rb │ ├── smart_factory_wrapper_spec.rb │ └── vcr_middleware_spec.rb └── spec_helper.rb ├── specs_e2e ├── cypress.config.js ├── playwright.config.js ├── rails_6_1 │ ├── .gitattributes │ ├── .gitignore │ ├── Gemfile │ ├── Rakefile │ ├── app │ │ ├── assets │ │ │ └── stylesheets │ │ │ │ └── application.css │ │ ├── controllers │ │ │ ├── application_controller.rb │ │ │ └── posts_controller.rb │ │ ├── helpers │ │ │ └── posts_helper.rb │ │ ├── jobs │ │ │ └── application_job.rb │ │ ├── models │ │ │ ├── application_record.rb │ │ │ └── post.rb │ │ └── views │ │ │ ├── layouts │ │ │ └── application.html.erb │ │ │ └── posts │ │ │ ├── _form.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── index.html.erb │ │ │ ├── new.html.erb │ │ │ └── show.html.erb │ ├── bin │ │ ├── bundle │ │ ├── rails │ │ ├── rake │ │ ├── setup │ │ ├── spring │ │ └── yarn │ ├── config.ru │ ├── config │ │ ├── application.rb │ │ ├── boot.rb │ │ ├── cable.yml │ │ ├── credentials.yml.enc │ │ ├── database.yml │ │ ├── environment.rb │ │ ├── environments │ │ │ ├── development.rb │ │ │ ├── production.rb │ │ │ └── test.rb │ │ ├── initializers │ │ │ ├── application_controller_renderer.rb │ │ │ ├── backtrace_silencers.rb │ │ │ ├── content_security_policy.rb │ │ │ ├── cookies_serializer.rb │ │ │ ├── filter_parameter_logging.rb │ │ │ ├── inflections.rb │ │ │ ├── mime_types.rb │ │ │ ├── permissions_policy.rb │ │ │ └── wrap_parameters.rb │ │ ├── locales │ │ │ └── en.yml │ │ ├── master.key │ │ ├── puma.rb │ │ ├── routes.rb │ │ └── storage.yml │ ├── db │ │ └── migrate │ │ │ └── 20180621085832_create_posts.rb │ ├── package.json │ ├── playwright-report │ │ └── index.html │ ├── public │ │ ├── 404.html │ │ ├── 422.html │ │ ├── 500.html │ │ ├── apple-touch-icon-precomposed.png │ │ ├── apple-touch-icon.png │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test-results │ │ └── .last-run.json │ ├── test.sh │ ├── test │ │ ├── controllers │ │ │ └── posts_controller_test.rb │ │ ├── cypress_fixtures │ │ │ └── posts.yml │ │ ├── fixtures │ │ │ └── posts.yml │ │ └── models │ │ │ └── post_test.rb │ └── vendor │ │ └── .keep ├── rails_7_2 │ ├── .gitattributes │ ├── .gitignore │ ├── .rubocop.yml │ ├── Gemfile │ ├── Rakefile │ ├── app │ │ ├── assets │ │ │ └── stylesheets │ │ │ │ └── application.css │ │ ├── controllers │ │ │ ├── application_controller.rb │ │ │ └── posts_controller.rb │ │ ├── helpers │ │ │ └── posts_helper.rb │ │ ├── jobs │ │ │ └── application_job.rb │ │ ├── models │ │ │ ├── application_record.rb │ │ │ └── post.rb │ │ └── views │ │ │ ├── layouts │ │ │ └── application.html.erb │ │ │ └── posts │ │ │ ├── _form.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── index.html.erb │ │ │ ├── new.html.erb │ │ │ └── show.html.erb │ ├── bin │ │ ├── brakeman │ │ ├── bundle │ │ ├── importmap │ │ ├── rails │ │ ├── rake │ │ └── setup │ ├── config.ru │ ├── config │ │ ├── application.rb │ │ ├── boot.rb │ │ ├── cable.yml │ │ ├── credentials.yml.enc │ │ ├── database.yml │ │ ├── environment.rb │ │ ├── environments │ │ │ ├── development.rb │ │ │ ├── production.rb │ │ │ └── test.rb │ │ ├── importmap.rb │ │ ├── initializers │ │ │ ├── content_security_policy.rb │ │ │ ├── filter_parameter_logging.rb │ │ │ ├── inflections.rb │ │ │ └── permissions_policy.rb │ │ ├── locales │ │ │ └── en.yml │ │ ├── master.key │ │ ├── puma.rb │ │ ├── routes.rb │ │ └── storage.yml │ ├── db │ │ ├── migrate │ │ │ └── 20180621085832_create_posts.rb │ │ ├── seeds.rb │ │ ├── test.sqlite3-shm │ │ └── test.sqlite3-wal │ ├── package.json │ ├── playwright-report │ │ └── index.html │ ├── public │ │ ├── 404.html │ │ ├── 406-unsupported-browser.html │ │ ├── 422.html │ │ ├── 500.html │ │ ├── icon.png │ │ ├── icon.svg │ │ └── robots.txt │ ├── storage │ │ └── test.sqlite3 │ ├── test-results │ │ └── .last-run.json │ ├── test.sh │ ├── test │ │ ├── controllers │ │ │ └── posts_controller_test.rb │ │ ├── cypress_fixtures │ │ │ └── posts.yml │ │ ├── fixtures │ │ │ └── posts.yml │ │ └── models │ │ │ └── post_test.rb │ └── vendor │ │ ├── .keep │ │ └── javascript │ │ └── .keep └── rails_8 │ ├── .gitattributes │ ├── .gitignore │ ├── .rubocop.yml │ ├── Gemfile │ ├── README.md │ ├── Rakefile │ ├── app │ ├── assets │ │ └── stylesheets │ │ │ └── application.css │ ├── controllers │ │ ├── application_controller.rb │ │ └── posts_controller.rb │ ├── helpers │ │ └── posts_helper.rb │ ├── jobs │ │ └── application_job.rb │ ├── models │ │ ├── application_record.rb │ │ └── post.rb │ └── views │ │ ├── layouts │ │ └── application.html.erb │ │ └── posts │ │ ├── _form.html.erb │ │ ├── edit.html.erb │ │ ├── index.html.erb │ │ ├── new.html.erb │ │ └── show.html.erb │ ├── bin │ ├── brakeman │ ├── bundle │ ├── dev │ ├── importmap │ ├── rails │ ├── rake │ ├── setup │ └── thrust │ ├── config.ru │ ├── config │ ├── application.rb │ ├── boot.rb │ ├── cable.yml │ ├── cache.yml │ ├── credentials.yml.enc │ ├── database.yml │ ├── deploy.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── importmap.rb │ ├── initializers │ │ ├── content_security_policy.rb │ │ ├── filter_parameter_logging.rb │ │ └── inflections.rb │ ├── locales │ │ └── en.yml │ ├── master.key │ ├── puma.rb │ ├── queue.yml │ ├── recurring.yml │ ├── routes.rb │ └── storage.yml │ ├── db │ ├── cable_schema.rb │ ├── cache_schema.rb │ ├── migrate │ │ └── 20180621085832_create_posts.rb │ ├── queue_schema.rb │ └── seeds.rb │ ├── package.json │ ├── playwright-report │ └── index.html │ ├── public │ ├── 400.html │ ├── 404.html │ ├── 406-unsupported-browser.html │ ├── 422.html │ ├── 500.html │ ├── icon.png │ ├── icon.svg │ └── robots.txt │ ├── storage │ ├── .keep │ ├── test.sqlite3 │ ├── test.sqlite3-shm │ └── test.sqlite3-wal │ ├── test-results │ └── .last-run.json │ ├── test.sh │ ├── test │ ├── application_system_test_case.rb │ ├── controllers │ │ └── posts_controller_test.rb │ ├── cypress_fixtures │ │ └── posts.yml │ ├── fixtures │ │ └── posts.yml │ ├── models │ │ └── post_test.rb │ └── test_helper.rb │ └── vendor │ ├── .keep │ └── javascript │ └── .keep └── tmp └── pids └── .gitkeep /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [shakacode] 2 | -------------------------------------------------------------------------------- /.github/workflows/ruby.yml: -------------------------------------------------------------------------------- 1 | name: Ruby 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | rails_6_1: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up Ruby 16 | uses: ruby/setup-ruby@v1 17 | with: 18 | ruby-version: 2.7.6 19 | bundler-cache: true 20 | - name: Run tests 21 | run: bundle exec rake 22 | - name: Run interaction tests 23 | run: ./specs_e2e/rails_6_1/test.sh 24 | env: 25 | CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} 26 | 27 | rails_7_2: 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | - name: Set up Ruby 33 | uses: ruby/setup-ruby@v1 34 | with: 35 | ruby-version: 3.1.3 36 | bundler-cache: true 37 | - name: Run tests 38 | run: bundle exec rake 39 | - run: gem uninstall -v '>= 2' -ax bundler || true 40 | - run: gem install bundler -v '< 2' 41 | - name: Run interaction tests 42 | run: ./specs_e2e/rails_7_2/test.sh 43 | env: 44 | CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} 45 | 46 | rails_8: 47 | runs-on: ubuntu-latest 48 | 49 | steps: 50 | - uses: actions/checkout@v4 51 | - name: Set up Ruby 52 | uses: ruby/setup-ruby@v1 53 | with: 54 | ruby-version: 3.2.2 55 | bundler-cache: true 56 | - name: Run tests 57 | run: bundle exec rake 58 | - run: gem uninstall -v '>= 2' -ax bundler || true 59 | - run: gem install bundler -v '< 2' 60 | - name: Run interaction tests 61 | run: ./specs_e2e/rails_8/test.sh 62 | env: 63 | CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Gemfile.lock 3 | .ruby-version 4 | spec/examples.txt 5 | .idea 6 | spec/test.log 7 | pkg/*.gem 8 | vendor/bundle 9 | .vscode 10 | node_modules 11 | package-lock.json 12 | yarn.lock 13 | specs_e2e/server.pid 14 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | gemspec 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ShakaCode 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | 4 | require 'rspec/core/rake_task' 5 | RSpec::Core::RakeTask.new(:spec) do |t| 6 | t.pattern = 'spec/cypress_on_rails/*_spec.rb' 7 | end 8 | 9 | task default: %w[spec build] 10 | -------------------------------------------------------------------------------- /cypress-on-rails.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $LOAD_PATH.push File.expand_path("../lib", __FILE__) 3 | require "cypress_on_rails/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "cypress-on-rails" 7 | s.version = CypressOnRails::VERSION 8 | s.author = ["miceportal team", 'Grant Petersen-Speelman'] 9 | s.email = ["info@miceportal.de", 'grantspeelman@gmail.com'] 10 | s.homepage = "http://github.com/shakacode/cypress-on-rails" 11 | s.summary = "Integrates cypress with rails or rack applications" 12 | s.description = "Integrates cypress with rails or rack applications" 13 | s.post_install_message = 'The CypressDev constant is being deprecated and will be completely removed and replaced with CypressOnRails.' 14 | s.files = `git ls-files`.split("\n") 15 | s.test_files = `git ls-files -- {spec}/*`.split("\n") 16 | s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } 17 | s.require_paths = ["lib"] 18 | s.add_dependency 'rack' 19 | s.add_development_dependency 'rake' 20 | s.add_development_dependency 'rspec' 21 | s.add_development_dependency 'railties', '>= 3.2' 22 | s.add_development_dependency 'factory_bot', '!= 6.4.5' 23 | s.add_development_dependency 'vcr' 24 | s.metadata = { 25 | "bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues", 26 | "changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md", 27 | "documentation_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/README.md", 28 | "homepage_uri" => "http://github.com/shakacode/cypress-on-rails", 29 | "source_code_uri" => "http://github.com/shakacode/cypress-on-rails" 30 | } 31 | end 32 | -------------------------------------------------------------------------------- /docs/authentication.md: -------------------------------------------------------------------------------- 1 | # Example for Authenticating a User 2 | 3 | In `config/routes.rb`: 4 | ```rb 5 | Rails.application.routes.draw do 6 | # ...... your other routes 7 | unless Rails.env.production? 8 | scope path: "/__cypress__", controller: 'cypress' do 9 | post "forceLogin", action: 'force_login' 10 | end 11 | end 12 | end 13 | ``` 14 | 15 | `app/controllers/cypress_controller.rb`: 16 | ```rb 17 | class CypressController < ApplicationController 18 | skip_before_action :verify_authenticity_token 19 | 20 | def force_login 21 | if params[:email].present? 22 | user = User.find_by!(email: params.require(:email)) 23 | else 24 | user = User.first! 25 | end 26 | sign_in(user) 27 | redirect_to URI.parse(params.require(:redirect_to)).path 28 | end 29 | end 30 | ``` 31 | 32 | In `cypress/support/on-rails.js`: 33 | ```js 34 | Cypress.Commands.add('forceLogin', (details) => { 35 | if (!details) { 36 | details = {} 37 | } 38 | 39 | if (!details.redirect_to) { 40 | details.redirect_to = '/' 41 | } 42 | 43 | cy.visit('__cypress__/forceLogin', 44 | { method: 'POST', body: { email: details.email, redirect_to: details.redirect_to } }) 45 | }) 46 | ``` 47 | 48 | Examples of usage in Cypress specs: 49 | ```js 50 | cy.forceLogin() 51 | cy.forceLogin({redirect_to: '/profile'}) 52 | cy.forceLogin({email: 'someuser@mail.com'}) 53 | ``` 54 | 55 | In `playwright/support/on-rails.js`: 56 | 57 | ```js 58 | async function forceLogin(page, { email, redirect_to = '/' }) { 59 | // Validate inputs 60 | if (typeof email !== 'string' || typeof redirect_to !== 'string') { 61 | throw new Error('Invalid input: email and redirect_to must be non-empty strings'); 62 | } 63 | 64 | const response = await page.request.post('/__e2e__/force_login', { 65 | data: { email: email, redirect_to: redirect_to }, 66 | headers: { 'Content-Type': 'application/json' } 67 | }); 68 | 69 | // Handle response based on status code 70 | if (response.ok()) { 71 | await page.goto(redirect_to); 72 | } else { 73 | // Throw an exception for specific error statuses 74 | throw new Error(`Login failed with status: ${response.status()}`); 75 | } 76 | } 77 | ``` 78 | 79 | Examples of usage in Playwright specs: 80 | ```js 81 | await forceLogin(page, { email: 'someuser@mail.com', redirect_to: '/profile' }); 82 | 83 | ``` -------------------------------------------------------------------------------- /docs/factory_bot_associations.md: -------------------------------------------------------------------------------- 1 | # Setting up associations with the correct data 2 | 3 | You cannot access associations directly from Cypress like you can do with Ruby tests. 4 | So setting up associations has to be done differently from within Cypress. 5 | 6 | There are a few ways you can setup associations with the correct data using Cypress and FactoryBot. 7 | 1. Setting the foreign keys 8 | 2. Using transient attributes 9 | 3. Using Nested Attributes 10 | 4. Combination of the above depending on your situation 11 | 12 | Assuming you have the following models 13 | 14 | ```rb 15 | class Post < ApplicationRecord 16 | belongs_to :author 17 | accepts_nested_attributes_for :author 18 | end 19 | 20 | class Author < ApplicationRecord 21 | has_many :posts 22 | accepts_nested_attributes_for :posts 23 | end 24 | ``` 25 | 26 | You can do the following: 27 | 28 | ## 1. Setting the foreign keys 29 | 30 | `factories.rb`: 31 | ```rb 32 | FactoryBot.define do 33 | factory :author do 34 | name { 'Taylor' } 35 | end 36 | 37 | factory :post do 38 | title { 'Cypress on Rails is Awesome' } 39 | author_id { create(:author).id } 40 | end 41 | end 42 | ``` 43 | 44 | then in Cypress 45 | ```js 46 | // example with overriding the defaults 47 | cy.appFactories([['create', 'author', { name: 'James' }]]).then((records) => { 48 | cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_id: records[0].id }]]) 49 | }) 50 | 51 | // example without overriding anything 52 | cy.appFactories([['create', 'author']]).then((records) => { 53 | cy.appFactories([['create', 'post', { author_id: records[0].id }]]) 54 | }) 55 | ``` 56 | 57 | then in Playwright 58 | There are a few ways you can set up associations with the correct data using Playwright and FactoryBot. 59 | ```js 60 | const records = await appFactories([['create', 'author', { name: 'James' }]], context); 61 | await appFactories([['create', 'post', { title: 'Playwright is cool', author_id: records[0].id }]], context); 62 | // Note: These Playwright examples demonstrate asynchronous interactions with the server for setting up data associations. Ensure that your environment is configured to handle these async operations. 63 | ``` 64 | 65 | 66 | ## 2. Using transient attributes 67 | 68 | ```rb 69 | FactoryBot.define do 70 | factory :author do 71 | name { 'Taylor' } 72 | end 73 | 74 | factory :post do 75 | transient do 76 | author_name { 'Taylor' } 77 | end 78 | title { 'Cypress on Rails is Awesome' } 79 | author { create(:author, name: author_name ) } 80 | end 81 | end 82 | ``` 83 | 84 | then in Cypress 85 | ```js 86 | // example with overriding the defaults 87 | cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_name: 'James' }]]) 88 | 89 | // example without overriding 90 | cy.appFactories([['create', 'post']]) 91 | ``` 92 | 93 | then in Playwright 94 | ```js 95 | const records = await appFactories([['create', 'post', { title: 'Playwright is cool', author_name: 'James' }]]); 96 | ``` 97 | 98 | ## 3. Using Nested Attributes 99 | 100 | ```rb 101 | FactoryBot.define do 102 | factory :author do 103 | name { 'Taylor' } 104 | end 105 | 106 | factory :post do 107 | title { 'Cypress on Rails is Awesome' } 108 | author_attributes { { name: 'Taylor' } } 109 | end 110 | end 111 | ``` 112 | 113 | then in Cypress 114 | ```js 115 | // example with overriding the defaults 116 | cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_attributes: { name: 'James' } }]]) 117 | 118 | // example without overriding 119 | cy.appFactories([['create', 'post']]) 120 | 121 | // example of creating author with multiple posts 122 | cy.appFactories([['create', 'author', { name: 'James', posts_attributes: [{ name: 'Cypress is cool' }, {name: 'Rails is awesome' }] }]]) 123 | ``` 124 | -------------------------------------------------------------------------------- /lib/cypress-on-rails.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/version' 2 | require 'cypress_on_rails/configuration' 3 | require_relative './cypress_on_rails/railtie' if defined?(Rails) 4 | 5 | # maintain backward compatibility 6 | CypressDev = CypressOnRails unless defined?(CypressDev) 7 | Cypress = CypressDev unless defined?(Cypress) 8 | -------------------------------------------------------------------------------- /lib/cypress/smart_factory_wrapper.rb: -------------------------------------------------------------------------------- 1 | require 'cypress-on-rails' 2 | require 'cypress_on_rails/smart_factory_wrapper' 3 | # for backward compatibility -------------------------------------------------------------------------------- /lib/cypress_dev.rb: -------------------------------------------------------------------------------- 1 | require 'cypress-on-rails' 2 | -------------------------------------------------------------------------------- /lib/cypress_dev/middleware.rb: -------------------------------------------------------------------------------- 1 | warn "cypress_dev is being deprecated, please require \"cypress_on_rails/middleware\" instead" 2 | require 'cypress_on_rails/middleware' 3 | -------------------------------------------------------------------------------- /lib/cypress_dev/smart_factory_wrapper.rb: -------------------------------------------------------------------------------- 1 | warn "cypress_dev is being deprecated, please require \"cypress_on_rails/smart_factory_wrapper\" instead" 2 | require 'cypress_on_rails/smart_factory_wrapper' 3 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/command_executor.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/configuration' 2 | 3 | module CypressOnRails 4 | # loads and evals the command files 5 | class CommandExecutor 6 | def self.perform(file,command_options = nil) 7 | load_e2e_helper 8 | file_data = File.read(file) 9 | eval file_data, binding, file 10 | rescue => e 11 | logger.error("fail to execute #{file}: #{e.message}") 12 | logger.error(e.backtrace.join("\n")) 13 | raise e 14 | end 15 | 16 | def self.load_e2e_helper 17 | e2e_helper_file = "#{configuration.install_folder}/e2e_helper.rb" 18 | cypress_helper_file = "#{configuration.install_folder}/cypress_helper.rb" 19 | if File.exist?(e2e_helper_file) 20 | Kernel.require e2e_helper_file 21 | elsif File.exist?(cypress_helper_file) 22 | Kernel.require cypress_helper_file 23 | warn "cypress_helper.rb is deprecated, please rename the file to e2e_helper.rb" 24 | else 25 | logger.warn "could not find #{e2e_helper_file} nor #{cypress_helper_file}" 26 | end 27 | end 28 | 29 | def self.logger 30 | configuration.logger 31 | end 32 | 33 | def self.configuration 34 | CypressOnRails.configuration 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/configuration.rb: -------------------------------------------------------------------------------- 1 | require 'logger' 2 | 3 | module CypressOnRails 4 | class Configuration 5 | attr_accessor :api_prefix 6 | attr_accessor :install_folder 7 | attr_accessor :use_middleware 8 | attr_accessor :use_vcr_middleware 9 | attr_accessor :before_request 10 | attr_accessor :logger 11 | 12 | # Attributes for backwards compatibility 13 | def cypress_folder 14 | warn "cypress_folder is deprecated, please use install_folder" 15 | install_folder 16 | end 17 | def cypress_folder=(v) 18 | warn "cypress_folder= is deprecated, please use install_folder" 19 | self.install_folder = v 20 | end 21 | 22 | def initialize 23 | reset 24 | end 25 | 26 | alias :use_middleware? :use_middleware 27 | alias :use_vcr_middleware? :use_vcr_middleware 28 | 29 | def reset 30 | self.api_prefix = '' 31 | self.install_folder = 'spec/e2e' 32 | self.use_middleware = true 33 | self.use_vcr_middleware = false 34 | self.before_request = -> (request) {} 35 | self.logger = Logger.new(STDOUT) 36 | end 37 | 38 | def tagged_logged 39 | if logger.respond_to?(:tagged) 40 | logger.tagged('CY_DEV') { yield } 41 | else 42 | yield 43 | end 44 | end 45 | end 46 | 47 | def self.configuration 48 | @configuration ||= Configuration.new 49 | end 50 | 51 | def self.configure 52 | yield configuration if block_given? 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/middleware.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'rack' 3 | require 'cypress_on_rails/middleware_config' 4 | require 'cypress_on_rails/command_executor' 5 | 6 | module CypressOnRails 7 | # Middleware to handle testing framework commands and eval 8 | class Middleware 9 | include MiddlewareConfig 10 | 11 | def initialize(app, command_executor = CommandExecutor, file = ::File) 12 | @app = app 13 | @command_executor = command_executor 14 | @file = file 15 | end 16 | 17 | def call(env) 18 | request = Rack::Request.new(env) 19 | if request.path.start_with?("#{configuration.api_prefix}/__e2e__/command") 20 | configuration.tagged_logged { handle_command(request) } 21 | elsif request.path.start_with?("#{configuration.api_prefix}/__cypress__/command") 22 | warn "/__cypress__/command is deprecated. Please use the install generator to use /__e2e__/command instead." 23 | configuration.tagged_logged { handle_command(request) } 24 | else 25 | @app.call(env) 26 | end 27 | end 28 | 29 | private 30 | 31 | Command = Struct.new(:name, :options, :install_folder) do 32 | # @return [Array] 33 | def self.from_body(body, configuration) 34 | if body.is_a?(Array) 35 | command_params = body 36 | else 37 | command_params = [body] 38 | end 39 | command_params.map do |params| 40 | new(params.fetch('name'), params['options'], configuration.install_folder) 41 | end 42 | end 43 | 44 | def file_path 45 | "#{install_folder}/app_commands/#{name}.rb" 46 | end 47 | end 48 | 49 | def handle_command(req) 50 | maybe_env = configuration.before_request.call(req) 51 | # Halt the middleware if an Rack Env was returned by `before_request` 52 | return maybe_env unless maybe_env.nil? 53 | 54 | req.body.rewind 55 | body = JSON.parse(req.body.read) 56 | logger.info "handle_command: #{body}" 57 | commands = Command.from_body(body, configuration) 58 | missing_command = commands.find {|command| !@file.exist?(command.file_path) } 59 | 60 | if missing_command.nil? 61 | begin 62 | results = commands.map { |command| @command_executor.perform(command.file_path, command.options) } 63 | 64 | begin 65 | output = results.to_json 66 | rescue NoMethodError 67 | output = {"message" => "Cannot convert to json"}.to_json 68 | end 69 | 70 | logger.debug "output: #{output}" 71 | [201, {'Content-Type' => 'application/json'}, [output]] 72 | rescue => e 73 | output = {"message" => e.message, "class" => e.class.to_s}.to_json 74 | [500, {'Content-Type' => 'application/json'}, [output]] 75 | end 76 | else 77 | output = {"message" => "could not find command file: #{missing_command.file_path}"}.to_json 78 | [404, {'Content-Type' => 'application/json'}, [output]] 79 | end 80 | end 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/middleware_config.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'rack' 3 | require 'cypress_on_rails/configuration' 4 | 5 | module CypressOnRails 6 | module MiddlewareConfig 7 | protected 8 | 9 | def configuration 10 | CypressOnRails.configuration 11 | end 12 | 13 | def logger 14 | configuration.logger 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'rails/railtie' 2 | require 'cypress_on_rails/configuration' 3 | 4 | module CypressOnRails 5 | class Railtie < Rails::Railtie 6 | initializer :setup_cypress_middleware, after: :load_config_initializers do |app| 7 | if CypressOnRails.configuration.use_middleware? 8 | require 'cypress_on_rails/middleware' 9 | app.middleware.use Middleware 10 | end 11 | if CypressOnRails.configuration.use_vcr_middleware? 12 | require 'cypress_on_rails/vcr_middleware' 13 | app.middleware.use VCRMiddleware 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/simple_rails_factory.rb: -------------------------------------------------------------------------------- 1 | module CypressOnRails 2 | module SimpleRailsFactory 3 | def self.create(type, *params) 4 | params = [{}] if params.empty? 5 | type.camelize.constantize.create!(*params) 6 | end 7 | 8 | def self.create_list(type, amount, *params) 9 | amount.to_i.times do 10 | create(type,*params) 11 | end 12 | end 13 | 14 | # to be API compatible with factorybot 15 | def self.definition_file_paths=(*); end 16 | def self.reload; end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/smart_factory_wrapper.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/configuration' 2 | require 'cypress_on_rails/simple_rails_factory' 3 | 4 | module CypressOnRails 5 | class SmartFactoryWrapper 6 | def self.instance 7 | @instance ||= new(files: [], factory: SimpleRailsFactory) 8 | end 9 | 10 | def self.configure(files:, factory:, always_reload: true) 11 | @instance = new(files: files, factory: factory, always_reload: always_reload) 12 | end 13 | 14 | def self.create(*args) 15 | instance.create(*args) 16 | end 17 | 18 | def self.create_list(*args) 19 | instance.create_list(*args) 20 | end 21 | 22 | def self.build(*args) 23 | instance.build(*args) 24 | end 25 | 26 | def self.build_list(*args) 27 | instance.build_list(*args) 28 | end 29 | 30 | def self.reload 31 | instance.reload 32 | end 33 | 34 | # @return [Array] 35 | attr_accessor :factory 36 | attr_accessor :always_reload 37 | 38 | def initialize(files:, factory:, always_reload: false, 39 | kernel: Kernel, file_system: File, dir_system: Dir) 40 | self.files = files 41 | self.factory = factory 42 | factory.definition_file_paths = [] 43 | self.always_reload = always_reload 44 | @kernel = kernel 45 | @file_system = file_system 46 | @latest_mtime = nil 47 | @dir_system = dir_system 48 | end 49 | 50 | def create(*options) 51 | auto_reload 52 | factory_name = options.shift 53 | if options.last.is_a?(Hash) 54 | args = options.pop 55 | else 56 | args = {} 57 | end 58 | factory.create(factory_name,*options.map(&:to_sym),args.symbolize_keys) 59 | end 60 | 61 | def create_list(*args) 62 | auto_reload 63 | factory.create_list(*args) 64 | end 65 | 66 | def build(*options) 67 | auto_reload 68 | factory_name = options.shift 69 | if options.last.is_a?(Hash) 70 | args = options.pop 71 | else 72 | args = {} 73 | end 74 | factory.build(factory_name, *options.map(&:to_sym), args.symbolize_keys) 75 | end 76 | 77 | def build_list(*args) 78 | auto_reload 79 | factory.build_list(*args) 80 | end 81 | 82 | def reload 83 | @latest_mtime = current_latest_mtime 84 | logger.info 'Loading Factories' 85 | factory.reload 86 | files.each do |file| 87 | logger.debug "-- Loading: #{file}" 88 | @kernel.load(file) 89 | end 90 | end 91 | 92 | private 93 | 94 | # @param [String,Array] arg 95 | def files=(array) 96 | array = [array] if array.is_a?(String) 97 | @dir_array = array 98 | end 99 | 100 | # @return [Array] 101 | def files 102 | Dir[*@dir_array] 103 | end 104 | 105 | def logger 106 | CypressOnRails.configuration.logger 107 | end 108 | 109 | def current_latest_mtime 110 | files.map{|file| @file_system.mtime(file) }.max 111 | end 112 | 113 | def auto_reload 114 | return unless should_reload? 115 | reload 116 | end 117 | 118 | def should_reload? 119 | @always_reload || @latest_mtime.nil? || @latest_mtime < current_latest_mtime 120 | end 121 | end 122 | end 123 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/vcr_middleware.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'rack' 3 | require 'cypress_on_rails/middleware_config' 4 | 5 | module CypressOnRails 6 | # Middleware to handle vcr 7 | class VCRMiddleware 8 | include MiddlewareConfig 9 | 10 | def initialize(app, vcr = nil) 11 | @app = app 12 | @vcr = vcr 13 | @first_call = false 14 | end 15 | 16 | def call(env) 17 | request = Rack::Request.new(env) 18 | if request.path.start_with?('/__e2e__/vcr/insert') 19 | configuration.tagged_logged { handle_insert(request) } 20 | elsif request.path.start_with?('/__e2e__/vcr/eject') 21 | configuration.tagged_logged { handle_eject } 22 | else 23 | do_first_call unless @first_call 24 | @app.call(env) 25 | end 26 | end 27 | 28 | private 29 | 30 | def handle_insert(req) 31 | WebMock.enable! if defined?(WebMock) 32 | vcr.turn_on! 33 | body = JSON.parse(req.body.read) 34 | logger.info "vcr insert cassette: #{body}" 35 | cassette_name = body[0] 36 | options = (body[1] || {}).symbolize_keys 37 | options[:record] = options[:record].to_sym if options[:record] 38 | options[:match_requests_on] = options[:match_requests_on].map(&:to_sym) if options[:match_requests_on] 39 | options[:serialize_with] = options[:serialize_with].to_sym if options[:serialize_with] 40 | options[:persist_with] = options[:persist_with].to_sym if options[:persist_with] 41 | vcr.insert_cassette(cassette_name, options) 42 | [201, {'Content-Type' => 'application/json'}, [{'message': 'OK'}.to_json]] 43 | rescue LoadError, ArgumentError => e 44 | [501, {'Content-Type' => 'application/json'}, [{'message': e.message}.to_json]] 45 | end 46 | 47 | def handle_eject 48 | logger.info "vcr eject cassette" 49 | vcr.eject_cassette 50 | do_first_call 51 | [201, {'Content-Type' => 'application/json'}, [{'message': 'OK'}.to_json]] 52 | rescue LoadError, ArgumentError => e 53 | [501, {'Content-Type' => 'application/json'}, [{'message': e.message}.to_json]] 54 | end 55 | 56 | def vcr 57 | return @vcr if @vcr 58 | require 'vcr' 59 | VCR.configure do |config| 60 | config.cassette_library_dir = "#{configuration.install_folder}/fixtures/vcr_cassettes" 61 | end 62 | @vcr = VCR 63 | end 64 | 65 | def do_first_call 66 | @first_call = true 67 | vcr.turn_off! 68 | WebMock.disable! if defined?(WebMock) 69 | rescue LoadError 70 | # nop 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /lib/cypress_on_rails/version.rb: -------------------------------------------------------------------------------- 1 | module CypressOnRails 2 | VERSION = '1.17.0'.freeze 3 | end 4 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/install_generator.rb: -------------------------------------------------------------------------------- 1 | module CypressOnRails 2 | class InstallGenerator < Rails::Generators::Base 3 | class_option :api_prefix, type: :string, default: '' 4 | class_option :framework, type: :string, default: 'cypress' 5 | class_option :install_folder, type: :string, default: 'e2e' 6 | class_option :install_with, type: :string, default: 'yarn' 7 | class_option :experimental, type: :boolean, default: false 8 | source_root File.expand_path('../templates', __FILE__) 9 | 10 | def install_framework 11 | directories = options.install_folder.split('/') 12 | directories.pop 13 | install_dir = "#{Dir.pwd}/#{directories.join('/')}" 14 | 15 | command = nil 16 | packages = [] 17 | packages = if options.framework == 'cypress' 18 | ['cypress', 'cypress-on-rails'] 19 | elsif options.framework == 'playwright' 20 | ['playwright', '@playwright/test'] 21 | end 22 | if options.install_with == 'yarn' 23 | command = "yarn --cwd=#{install_dir} add #{packages.join(' ')} --dev" 24 | elsif options.install_with == 'npm' 25 | command = "cd #{install_dir}; npm install #{packages.join(' ')} --save-dev" 26 | end 27 | if command 28 | say command 29 | fail "failed to install #{packages.join(' ')}" unless system(command) 30 | end 31 | 32 | if options.framework == 'cypress' 33 | template "spec/cypress/support/index.js.erb", "#{options.install_folder}/cypress/support/index.js" 34 | copy_file "spec/cypress/support/commands.js", "#{options.install_folder}/cypress/support/commands.js" 35 | copy_file "spec/cypress.config.js", "#{options.install_folder}/cypress.config.js" 36 | end 37 | if options.framework == 'playwright' 38 | template "spec/playwright/support/index.js.erb", "#{options.install_folder}/playwright/support/index.js" 39 | copy_file "spec/playwright.config.js", "#{options.install_folder}/playwright.config.js" 40 | end 41 | end 42 | 43 | def add_initial_files 44 | template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb" 45 | template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/#{options.framework}/e2e_helper.rb" 46 | directory 'spec/e2e/app_commands', "#{options.install_folder}/#{options.framework}/app_commands" 47 | if options.framework == 'cypress' 48 | copy_file "spec/cypress/support/on-rails.js", "#{options.install_folder}/cypress/support/on-rails.js" 49 | directory 'spec/cypress/e2e/rails_examples', "#{options.install_folder}/cypress/e2e/rails_examples" 50 | end 51 | if options.framework == 'playwright' 52 | copy_file "spec/playwright/support/on-rails.js", "#{options.install_folder}/playwright/support/on-rails.js" 53 | directory 'spec/playwright/e2e/rails_examples', "#{options.install_folder}/playwright/e2e/rails_examples" 54 | end 55 | end 56 | 57 | def update_files 58 | if options.framework == 'cypress' 59 | append_to_file "#{options.install_folder}/cypress/support/index.js", 60 | "\nimport './on-rails'", 61 | after: 'import \'./commands\'' 62 | end 63 | if options.framework == 'playwright' 64 | append_to_file "#{options.install_folder}/playwright/support/index.js", 65 | "\nimport './on-rails'", 66 | after: '// Import commands.js using ES2015 syntax:' 67 | end 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb: -------------------------------------------------------------------------------- 1 | if defined?(CypressOnRails) 2 | CypressOnRails.configure do |c| 3 | c.api_prefix = "<%= options.api_prefix %>" 4 | c.install_folder = File.expand_path("#{__dir__}/../../<%= options.install_folder %>/<%= options.framework %>") 5 | # WARNING!! CypressOnRails can execute arbitrary ruby code 6 | # please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0 7 | c.use_middleware = !Rails.env.production? 8 | <% unless options.experimental %># <% end %> c.use_vcr_middleware = !Rails.env.production? 9 | c.logger = Rails.logger 10 | 11 | # If you want to enable a before_request logic, such as authentication, logging, sending metrics, etc. 12 | # Refer to https://www.rubydoc.info/gems/rack/Rack/Request for the `request` argument. 13 | # Return nil to continue through the Cypress command. Return a response [status, header, body] to halt. 14 | # c.before_request = lambda { |request| 15 | # unless request.env['warden'].authenticate(:secret_key) 16 | # return [403, {}, ["forbidden"]] 17 | # end 18 | # } 19 | end 20 | 21 | # # if you compile your asssets on CI 22 | # if ENV['CYPRESS'].present? && ENV['CI'].present? 23 | # Rails.application.configure do 24 | # config.assets.compile = false 25 | # config.assets.unknown_asset_fallback = false 26 | # end 27 | # end 28 | end 29 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('cypress') 2 | 3 | module.exports = defineConfig({ 4 | e2e: { 5 | baseUrl: "http://localhost:5017", 6 | defaultCommandTimeout: 10000, 7 | supportFile: "cypress/support/index.js", 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/advance_factory_bot.cy.js: -------------------------------------------------------------------------------- 1 | describe('More Rails using factory bot examples', function() { 2 | beforeEach(() => { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | }) 5 | 6 | it('using response from factory bot', function() { 7 | cy.appFactories([['create', 'post', { title: 'Good bye Mars'} ]]).then((results) => { 8 | const record = results[0]; 9 | 10 | cy.visit(`/posts/${record.id}`); 11 | }); 12 | cy.contains("Good bye Mars") 13 | }) 14 | 15 | it('using response from multiple factory bot', function() { 16 | cy.appFactories([ 17 | ['create', 'post', { title: 'My First Post'} ], 18 | ['create', 'post', { title: 'My Second Post'} ] 19 | ]).then((results) => { 20 | cy.visit(`/posts/${results[0].id}`); 21 | cy.contains("My First Post") 22 | 23 | cy.visit(`/posts/${results[1].id}`); 24 | cy.contains("My Second Post") 25 | }); 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/other.cy.js: -------------------------------------------------------------------------------- 1 | describe('Rails Other examples', function() { 2 | it('cypress eval', function() { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | cy.appEval("Post.create(title: 'Hello Eval')") 5 | 6 | cy.visit('/') 7 | cy.get('table').find('tbody').should(($tbody) => { 8 | expect($tbody).not.to.contain('Multi Command') 9 | expect($tbody).to.contain('Hello Eval') 10 | }) 11 | }) 12 | 13 | it('runs multiple commands', function() { 14 | cy.appCommands([{ name: 'clean' }, 15 | { name: 'scenarios/basic' }, 16 | { name: 'eval', options: "Post.create(title: 'Multi Command')" }]) 17 | cy.visit('/') 18 | 19 | cy.get('table').find('tbody').should(($tbody) => { 20 | expect($tbody).not.to.contain('Hello Eval') 21 | expect($tbody).to.contain('Multi Command') 22 | expect($tbody).to.contain('I am a Postman') 23 | }) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_factory_bot.cy.js: -------------------------------------------------------------------------------- 1 | describe('Rails using factory bot examples', function() { 2 | beforeEach(() => { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | }) 5 | 6 | it('using single factory bot', function() { 7 | cy.appFactories([ 8 | ['create', 'post', {title: 'Good bye Mars'} ] 9 | ]) 10 | cy.visit('/') 11 | cy.get('table').find('tbody').should(($tbody) => { 12 | // clean should of removed these from other tests 13 | expect($tbody).not.to.contain('Hello World') 14 | 15 | expect($tbody).to.contain('Good bye Mars') 16 | }) 17 | }) 18 | 19 | it('using multiple factory bot', function() { 20 | cy.appFactories([ 21 | ['create_list', 'post', 10], 22 | ['create', 'post', {title: 'Hello World'} ] 23 | ]) 24 | cy.visit('/') 25 | cy.get('table').find('tbody').should(($tbody) => { 26 | // clean should of removed these from other tests 27 | expect($tbody).to.contain('Hello World') 28 | expect($tbody).not.to.contain('Good bye Mars') 29 | }) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_fixtures.cy.js: -------------------------------------------------------------------------------- 1 | describe('Rails using rails fixtures examples', function() { 2 | beforeEach(() => { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | }) 5 | 6 | it('loading all fixtures', function() { 7 | cy.appFixtures() 8 | cy.visit('/') 9 | cy.get('table').find('tbody').should(($tbody) => { 10 | expect($tbody).to.contain('MyRailsFixtures') 11 | expect($tbody).to.contain('MyRailsFixtures2') 12 | }) 13 | }) 14 | 15 | it('using single rails fixtures', function() { 16 | cy.appFixtures({fixtures: ['posts']}) 17 | cy.visit('/') 18 | cy.get('table').find('tbody').should(($tbody) => { 19 | expect($tbody).to.contain('MyRailsFixtures') 20 | expect($tbody).to.contain('MyRailsFixtures2') 21 | }) 22 | }) 23 | 24 | it('loading another folder of fixtures', function() { 25 | cy.appFixtures({fixtures_dir: 'test/cypress_fixtures' }) 26 | cy.visit('/') 27 | cy.get('table').find('tbody').should(($tbody) => { 28 | expect($tbody).to.contain('MyCypressFixtures') 29 | expect($tbody).to.contain('MyCypressFixtures2') 30 | }) 31 | }) 32 | }) 33 | 34 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_scenarios.cy.js: -------------------------------------------------------------------------------- 1 | describe('Rails using scenarios examples', function() { 2 | beforeEach(() => { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | }) 5 | 6 | it('setup basic scenario', function() { 7 | cy.appScenario('basic') 8 | cy.visit('/') 9 | cy.get('table').find('tbody').should(($tbody) => { 10 | // clean should of removed these from other tests 11 | expect($tbody).not.to.contain('Good bye Mars') 12 | expect($tbody).not.to.contain('Hello World') 13 | 14 | expect($tbody).to.contain('I am a Postman') 15 | }) 16 | }) 17 | 18 | 19 | it('example of missing scenario failure', function() { 20 | cy.visit('/') 21 | cy.appScenario('basic') 22 | // cy.appScenario('missing') // uncomment these if you want to see what happens 23 | }) 24 | 25 | it('example of missing app failure', function() { 26 | cy.visit('/') 27 | cy.appScenario('basic') 28 | // cy.app('run_me') // uncomment these if you want to see what happens 29 | }) 30 | }) 31 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js: -------------------------------------------------------------------------------- 1 | describe('Rails Other examples', function() { 2 | it('Inserting a cassette', function() { 3 | cy.app('clean') // have a look at e2e/app_commands/clean.rb 4 | 5 | cy.vcr_insert_cassette('cats', { record: "new_episodes" }) 6 | cy.visit('/using_vcr/index') 7 | 8 | cy.get('a').contains('Cats').click() 9 | cy.contains('Record from Cats API'); 10 | 11 | cy.vcr_eject_cassette(); 12 | }) 13 | 14 | it('Using previous a cassette', function() { 15 | cy.app('clean') // have a look at cypress/app_commands/clean.rb 16 | 17 | cy.vcr_insert_cassette('cats') 18 | cy.visit('/using_vcr/index') 19 | cy.get('a').contains('Cats').click() 20 | cy.contains('Record from Cats API'); 21 | 22 | cy.vcr_eject_cassette(); 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add("login", (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This is will overwrite an existing command -- 25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/support/index.js.erb: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | <% unless options.experimental %>// <% end %>import 'cypress-on-rails/support/index' 18 | import './commands' 19 | import './on-rails' 20 | 21 | // Alternatively you can use CommonJS syntax: 22 | // require('./commands') 23 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js: -------------------------------------------------------------------------------- 1 | // CypressOnRails: dont remove these command 2 | Cypress.Commands.add('appCommands', function (body) { 3 | Object.keys(body).forEach(key => body[key] === undefined ? delete body[key] : {}); 4 | const log = Cypress.log({ name: "APP", message: body, autoEnd: false }) 5 | return cy.request({ 6 | method: 'POST', 7 | url: "/__e2e__/command", 8 | body: JSON.stringify(body), 9 | headers: { 10 | 'Content-Type': 'application/json', 11 | }, 12 | log: false, 13 | failOnStatusCode: false 14 | }).then((response) => { 15 | log.end(); 16 | if (response.status !== 201) { 17 | expect(response.body.message).to.equal('') 18 | expect(response.status).to.be.equal(201) 19 | } 20 | return response.body 21 | }); 22 | }); 23 | 24 | Cypress.Commands.add('app', function (name, command_options) { 25 | return cy.appCommands({name: name, options: command_options}).then((body) => { 26 | return body[0] 27 | }); 28 | }); 29 | 30 | Cypress.Commands.add('appScenario', function (name, options = {}) { 31 | return cy.app('scenarios/' + name, options) 32 | }); 33 | 34 | Cypress.Commands.add('appEval', function (code) { 35 | return cy.app('eval', code) 36 | }); 37 | 38 | Cypress.Commands.add('appFactories', function (options) { 39 | return cy.app('factory_bot', options) 40 | }); 41 | 42 | Cypress.Commands.add('appFixtures', function (options) { 43 | cy.app('activerecord_fixtures', options) 44 | }); 45 | // CypressOnRails: end 46 | 47 | // The next is optional 48 | // beforeEach(() => { 49 | // cy.app('clean') // have a look at cypress/app_commands/clean.rb 50 | // }); 51 | 52 | // comment this out if you do not want to attempt to log additional info on test fail 53 | Cypress.on('fail', (err, runnable) => { 54 | // allow app to generate additional logging data 55 | Cypress.$.ajax({ 56 | url: '/__e2e__/command', 57 | data: JSON.stringify({name: 'log_fail', options: {error_message: err.message, runnable_full_title: runnable.fullTitle() }}), 58 | headers: { 59 | 'Content-Type': 'application/json', 60 | }, 61 | async: false, 62 | method: 'POST' 63 | }); 64 | 65 | throw err; 66 | }); 67 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/activerecord_fixtures.rb: -------------------------------------------------------------------------------- 1 | # you can delete this file if you don't use Rails Test Fixtures 2 | 3 | fixtures_dir = command_options.try(:[], 'fixtures_dir') 4 | fixture_files = command_options.try(:[], 'fixtures') 5 | 6 | if defined?(ActiveRecord) 7 | require "active_record/fixtures" 8 | 9 | fixtures_dir ||= ActiveRecord::Tasks::DatabaseTasks.fixtures_path 10 | fixture_files ||= Dir["#{fixtures_dir}/**/*.yml"].map { |f| f[(fixtures_dir.size + 1)..-5] } 11 | 12 | logger.debug "loading fixtures: { dir: #{fixtures_dir}, files: #{fixture_files} }" 13 | ActiveRecord::FixtureSet.reset_cache 14 | ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files) 15 | "Fixtures Done" # this gets returned 16 | else # this else part can be removed 17 | logger.error "Looks like activerecord_fixtures has to be modified to suite your need" 18 | Post.create(title: 'MyCypressFixtures') 19 | Post.create(title: 'MyCypressFixtures2') 20 | Post.create(title: 'MyRailsFixtures') 21 | Post.create(title: 'MyRailsFixtures2') 22 | end 23 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/clean.rb: -------------------------------------------------------------------------------- 1 | if defined?(DatabaseCleaner) 2 | # cleaning the database using database_cleaner 3 | DatabaseCleaner.strategy = :truncation 4 | DatabaseCleaner.clean 5 | else 6 | logger.warn "add database_cleaner or update cypress/app_commands/clean.rb" 7 | Post.delete_all if defined?(Post) 8 | end 9 | 10 | CypressOnRails::SmartFactoryWrapper.reload 11 | 12 | if defined?(VCR) 13 | VCR.eject_cassette # make sure we no cassette inserted before the next test starts 14 | VCR.turn_off! 15 | WebMock.disable! if defined?(WebMock) 16 | end 17 | 18 | Rails.logger.info "APPCLEANED" # used by log_fail.rb 19 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/eval.rb: -------------------------------------------------------------------------------- 1 | Kernel.eval(command_options) unless command_options.nil? 2 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/factory_bot.rb: -------------------------------------------------------------------------------- 1 | Array.wrap(command_options).map do |factory_options| 2 | factory_method = factory_options.shift 3 | begin 4 | logger.debug "running #{factory_method}, #{factory_options}" 5 | CypressOnRails::SmartFactoryWrapper.public_send(factory_method, *factory_options) 6 | rescue => e 7 | logger.error "#{e.class}: #{e.message}" 8 | logger.error e.backtrace.join("\n") 9 | logger.error "#{e.record.inspect}" if e.is_a?(ActiveRecord::RecordInvalid) 10 | raise e 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/log_fail.rb: -------------------------------------------------------------------------------- 1 | # This file is called when a cypress spec fails and allows for extra logging to be captured 2 | filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '') 3 | 4 | # grab last lines until "APPCLEANED" (Make sure in clean.rb to log the text "APPCLEANED") 5 | system "tail -n 10000 -r log/#{Rails.env}.log | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'" 6 | # Alternative command if the above does not work 7 | # system "tail -n 10000 log/#{Rails.env}.log | tac | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'" 8 | 9 | # create a json debug file for server debugging 10 | json_result = {} 11 | json_result['error'] = command_options.fetch('error_message', 'no error message') 12 | 13 | if defined?(ActiveRecord::Base) 14 | json_result['records'] = 15 | ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records| 16 | begin 17 | records[record_class.to_s] = record_class.limit(100).map(&:attributes) 18 | rescue 19 | end 20 | end 21 | end 22 | 23 | filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '') 24 | File.open("#{Rails.root}/log/#{filename}.json", "w+") do |file| 25 | file << JSON.pretty_generate(json_result) 26 | end 27 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/app_commands/scenarios/basic.rb: -------------------------------------------------------------------------------- 1 | # You can setup your Rails state here 2 | # MyModel.create name: 'something' 3 | Post.create(title: 'I am a Postman') 4 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/e2e/e2e_helper.rb.erb: -------------------------------------------------------------------------------- 1 | # This is loaded once before the first command is executed 2 | 3 | begin 4 | require 'database_cleaner-active_record' 5 | rescue LoadError => e 6 | puts e.message 7 | begin 8 | require 'database_cleaner' 9 | rescue LoadError => e 10 | puts e.message 11 | end 12 | end 13 | 14 | begin 15 | require 'factory_bot_rails' 16 | rescue LoadError => e 17 | puts e.message 18 | begin 19 | require 'factory_girl_rails' 20 | rescue LoadError => e 21 | puts e.message 22 | end 23 | end 24 | 25 | require 'cypress_on_rails/smart_factory_wrapper' 26 | 27 | factory = CypressOnRails::SimpleRailsFactory 28 | factory = FactoryBot if defined?(FactoryBot) 29 | factory = FactoryGirl if defined?(FactoryGirl) 30 | 31 | CypressOnRails::SmartFactoryWrapper.configure( 32 | always_reload: false, 33 | factory: factory, 34 | files: [ 35 | Rails.root.join('spec', 'factories.rb'), 36 | Rails.root.join('spec', 'factories', '**', '*.rb') 37 | ] 38 | ) 39 | 40 | <% unless options.experimental %># <% end %>require 'vcr' 41 | <% unless options.experimental %># <% end %>VCR.configure do |config| 42 | <% unless options.experimental %># <% end %> config.hook_into :webmock 43 | <% unless options.experimental %># <% end %>end 44 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/playwright.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { defineConfig, devices } = require('@playwright/test'); 3 | 4 | /** 5 | * Read environment variables from file. 6 | * https://github.com/motdotla/dotenv 7 | */ 8 | // require('dotenv').config(); 9 | 10 | /** 11 | * @see https://playwright.dev/docs/test-configuration 12 | */ 13 | module.exports = defineConfig({ 14 | testDir: './playwright/e2e', 15 | /* Run tests in files in parallel */ 16 | fullyParallel: true, 17 | /* Fail the build on CI if you accidentally left test.only in the source code. */ 18 | forbidOnly: !!process.env.CI, 19 | /* Retry on CI only */ 20 | retries: process.env.CI ? 2 : 0, 21 | /* Opt out of parallel tests on CI. */ 22 | workers: process.env.CI ? 1 : undefined, 23 | /* Reporter to use. See https://playwright.dev/docs/test-reporters */ 24 | reporter: 'html', 25 | /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ 26 | use: { 27 | /* Base URL to use in actions like `await page.goto('/')`. */ 28 | baseURL: 'http://127.0.0.1:5017', 29 | 30 | /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ 31 | trace: 'on-first-retry', 32 | }, 33 | 34 | /* Configure projects for major browsers */ 35 | projects: [ 36 | { 37 | name: 'chromium', 38 | use: { ...devices['Desktop Chrome'] }, 39 | }, 40 | 41 | { 42 | name: 'firefox', 43 | use: { ...devices['Desktop Firefox'] }, 44 | }, 45 | 46 | { 47 | name: 'webkit', 48 | use: { ...devices['Desktop Safari'] }, 49 | }, 50 | 51 | /* Test against mobile viewports. */ 52 | // { 53 | // name: 'Mobile Chrome', 54 | // use: { ...devices['Pixel 5'] }, 55 | // }, 56 | // { 57 | // name: 'Mobile Safari', 58 | // use: { ...devices['iPhone 12'] }, 59 | // }, 60 | 61 | /* Test against branded browsers. */ 62 | // { 63 | // name: 'Microsoft Edge', 64 | // use: { ...devices['Desktop Edge'], channel: 'msedge' }, 65 | // }, 66 | // { 67 | // name: 'Google Chrome', 68 | // use: { ..devices['Desktop Chrome'], channel: 'chrome' }, 69 | // }, 70 | ], 71 | 72 | /* Run your local dev server before starting the tests */ 73 | // webServer: { 74 | // command: 'npm run start', 75 | // url: 'http://127.0.0.1:3000', 76 | // reuseExistingServer: !process.env.CI, 77 | // }, 78 | }); 79 | 80 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/playwright/e2e/rails_examples/using_scenarios.spec.js: -------------------------------------------------------------------------------- 1 | import { test, expect } from "@playwright/test"; 2 | import { app, appScenario } from '../../support/on-rails'; 3 | 4 | test.describe("Rails using scenarios examples", () => { 5 | test.beforeEach(async ({ page }) => { 6 | await app('clean'); 7 | }); 8 | 9 | test("setup basic scenario", async ({ page }) => { 10 | await appScenario('basic'); 11 | await page.goto("/"); }); 12 | }); 13 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/playwright/support/index.js.erb: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './on-rails' 18 | <% unless options.experimental %>// <% end %>import 'cypress-on-rails/support/index' 19 | 20 | // Alternatively you can use CommonJS syntax: 21 | // require('./commands') 22 | -------------------------------------------------------------------------------- /lib/generators/cypress_on_rails/templates/spec/playwright/support/on-rails.js: -------------------------------------------------------------------------------- 1 | import { request, expect } from '@playwright/test' 2 | import config from '../../playwright.config' 3 | 4 | const contextPromise = request.newContext({ baseURL: config.use ? config.use.baseURL : 'http://localhost:5017' }) 5 | 6 | const appCommands = async (data) => { 7 | const context = await contextPromise 8 | const response = await context.post('/__e2e__/command', { data }) 9 | 10 | expect(response.ok()).toBeTruthy() 11 | return response.body 12 | } 13 | 14 | const app = (name, options = {}) => appCommands({ name, options }).then((body) => body[0]) 15 | const appScenario = (name, options = {}) => app('scenarios/' + name, options) 16 | const appEval = (code) => app('eval', code) 17 | const appFactories = (options) => app('factory_bot', options) 18 | 19 | const appVcrInsertCassette = async (cassette_name, options) => { 20 | const context = await contextPromise; 21 | if (!options) options = {}; 22 | 23 | Object.keys(options).forEach(key => options[key] === undefined ? delete options[key] : {}); 24 | const response = await context.post("/__e2e__/vcr/insert", {data: [cassette_name,options]}); 25 | expect(response.ok()).toBeTruthy(); 26 | return response.body; 27 | } 28 | 29 | const appVcrEjectCassette = async () => { 30 | const context = await contextPromise; 31 | 32 | const response = await context.post("/__e2e__/vcr/eject"); 33 | expect(response.ok()).toBeTruthy(); 34 | return response.body; 35 | } 36 | 37 | export { appCommands, app, appScenario, appEval, appFactories, appVcrInsertCassette, appVcrEjectCassette } 38 | -------------------------------------------------------------------------------- /plugin/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /plugin/cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | // export a function 2 | module.exports = (on, config) => { 3 | // configure plugins here 4 | } 5 | -------------------------------------------------------------------------------- /plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cypress-on-rails", 3 | "version": "0.1.0", 4 | "description": "Integrates cypress with rails or rack applications", 5 | "main": "cypress/index.js", 6 | "directories": { 7 | "src": "cypress" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "build": "tsc" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/shakacode/cypress-on-rails.git" 16 | }, 17 | "keywords": [ 18 | "cypress", 19 | "ruby", 20 | "rails" 21 | ], 22 | "author": "Grant Petersen-Speelman", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/shakacode/cypress-on-rails/issues" 26 | }, 27 | "homepage": "https://github.com/shakacode/cypress-on-rails#readme", 28 | "dependencies": { 29 | "cypress": "*" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /plugin/support/index.js: -------------------------------------------------------------------------------- 1 | Cypress.Commands.add("vcr_insert_cassette", (cassette_name, options) => { 2 | if (!options) options = {}; 3 | 4 | Object.keys(options).forEach(key => options[key] === undefined ? delete options[key] : {}); 5 | const log = Cypress.log({ name: "VCR Insert", message: cassette_name, autoEnd: false }) 6 | return cy.request({ 7 | method: 'POST', 8 | url: "/__e2e__/vcr/insert", 9 | body: JSON.stringify([cassette_name,options]), 10 | log: false, 11 | failOnStatusCode: false 12 | }).then((response) => { 13 | log.end(); 14 | if (response.status !== 201) { 15 | expect(response.body.message).to.equal('') 16 | expect(response.status).to.be.equal(201) 17 | } 18 | return response.body 19 | }); 20 | }); 21 | 22 | Cypress.Commands.add("vcr_eject_cassette", () => { 23 | const log = Cypress.log({ name: "VCR Eject", autoEnd: false }) 24 | return cy.request({ 25 | method: 'POST', 26 | url: "/__e2e__/vcr/eject", 27 | log: false, 28 | failOnStatusCode: false 29 | }).then((response) => { 30 | log.end(); 31 | if (response.status !== 201) { 32 | expect(response.body.message).to.equal('') 33 | expect(response.status).to.be.equal(201) 34 | } 35 | return response.body 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/command_executor/e2e_helper.rb: -------------------------------------------------------------------------------- 1 | class DummyTest 2 | # @return [Array] 3 | def self.values 4 | @values ||= [] 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/command_executor/test_command.rb: -------------------------------------------------------------------------------- 1 | DummyTest.values << 'hello' 2 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/command_executor/test_command_with_options.rb: -------------------------------------------------------------------------------- 1 | DummyTest.values << command_options 2 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/command_executor_spec.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/command_executor' 2 | 3 | RSpec.describe CypressOnRails::CommandExecutor do 4 | describe '.perform' do 5 | let(:folder) { "#{__dir__}/command_executor" } 6 | subject { described_class } 7 | 8 | def executor_perform(*values) 9 | subject.perform(*values) 10 | end 11 | 12 | before do 13 | CypressOnRails.configuration.install_folder = folder 14 | DummyTest.values.clear if defined?(DummyTest) 15 | end 16 | 17 | it 'runs test command' do 18 | executor_perform("#{folder}/test_command.rb") 19 | expect(DummyTest.values).to eq(%w(hello)) 20 | end 21 | 22 | it 'runs test command twice' do 23 | executor_perform("#{folder}/test_command.rb") 24 | executor_perform("#{folder}/test_command.rb") 25 | expect(DummyTest.values).to eq(%w(hello hello)) 26 | end 27 | 28 | it 'runs command with options' do 29 | executor_perform("#{folder}/test_command_with_options.rb", 'my_string') 30 | expect(DummyTest.values).to eq(%w(my_string)) 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/configuration_spec.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/configuration' 2 | 3 | RSpec.describe CypressOnRails::Configuration do 4 | it 'has defaults' do 5 | CypressOnRails.configure { |config| config.reset } 6 | 7 | expect(CypressOnRails.configuration.api_prefix).to eq('') 8 | expect(CypressOnRails.configuration.install_folder).to eq('spec/e2e') 9 | expect(CypressOnRails.configuration.use_middleware?).to eq(true) 10 | expect(CypressOnRails.configuration.logger).to_not be_nil 11 | expect(CypressOnRails.configuration.before_request).to_not be_nil 12 | end 13 | 14 | it 'can be configured' do 15 | my_logger = Logger.new(STDOUT) 16 | before_request_lambda = -> (_) { return [200, {}, ['hello world']] } 17 | CypressOnRails.configure do |config| 18 | config.api_prefix = '/api' 19 | config.install_folder = 'my/path' 20 | config.use_middleware = false 21 | config.logger = my_logger 22 | config.before_request = before_request_lambda 23 | end 24 | expect(CypressOnRails.configuration.api_prefix).to eq('/api') 25 | expect(CypressOnRails.configuration.install_folder).to eq('my/path') 26 | expect(CypressOnRails.configuration.use_middleware?).to eq(false) 27 | expect(CypressOnRails.configuration.logger).to eq(my_logger) 28 | expect(CypressOnRails.configuration.before_request).to eq(before_request_lambda) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/railtie_spec.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/railtie' 2 | 3 | module Rails 4 | def self.env 5 | end 6 | end 7 | 8 | RSpec.describe CypressOnRails::Railtie do 9 | let(:rails_env) { double } 10 | let(:middleware) { double('Middleware', use: true) } 11 | let(:rails_app) { double('RailsApp', middleware: middleware) } 12 | 13 | before do 14 | allow(Rails).to receive(:env).and_return(rails_env) 15 | end 16 | 17 | it 'runs the middleware in test mode' do 18 | CypressOnRails::Railtie.initializers.each do |initializer| 19 | initializer.run(rails_app) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/cypress_on_rails/simple_rails_factory_spec.rb: -------------------------------------------------------------------------------- 1 | require 'cypress_on_rails/simple_rails_factory' 2 | 3 | RSpec.describe CypressOnRails::SimpleRailsFactory do 4 | subject { CypressOnRails::SimpleRailsFactory } 5 | 6 | class AppRecord 7 | def self.create!(*) 8 | end 9 | end 10 | 11 | before { allow(AppRecord).to receive(:create!) } 12 | 13 | it do 14 | subject.create('AppRecord', { my_args: 'Hello World' }) 15 | 16 | expect(AppRecord).to have_received(:create!).with( { my_args: 'Hello World' } ) 17 | end 18 | 19 | it do 20 | subject.create('AppRecord', 'trait', { my_args: 'Hello World' }) 21 | 22 | expect(AppRecord).to have_received(:create!).with( 'trait', { my_args: 'Hello World' } ) 23 | end 24 | 25 | it do 26 | subject.create('AppRecord') 27 | 28 | expect(AppRecord).to have_received(:create!).with( { } ) 29 | end 30 | 31 | it do 32 | expect{ subject.create('UnknownRecord', { my_args: 'Hello World' }) }. 33 | to raise_error(NameError) 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /specs_e2e/cypress.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('cypress') 2 | 3 | module.exports = defineConfig({ 4 | projectId: "2b6cjr", 5 | e2e: { 6 | baseUrl: "http://localhost:5017", 7 | defaultCommandTimeout: 10000, 8 | supportFile: "cypress/support/index.js" 9 | } 10 | }) 11 | -------------------------------------------------------------------------------- /specs_e2e/playwright.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { defineConfig, devices } = require('@playwright/test'); 3 | 4 | /** 5 | * Read environment variables from file. 6 | * https://github.com/motdotla/dotenv 7 | */ 8 | // require('dotenv').config(); 9 | 10 | /** 11 | * @see https://playwright.dev/docs/test-configuration 12 | */ 13 | module.exports = defineConfig({ 14 | testDir: './playwright/e2e', 15 | /* Run tests in files in parallel */ 16 | fullyParallel: true, 17 | /* Fail the build on CI if you accidentally left test.only in the source code. */ 18 | forbidOnly: !!process.env.CI, 19 | /* Retry on CI only */ 20 | retries: process.env.CI ? 2 : 0, 21 | /* Opt out of parallel tests on CI. */ 22 | workers: process.env.CI ? 1 : undefined, 23 | /* Reporter to use. See https://playwright.dev/docs/test-reporters */ 24 | reporter: 'html', 25 | /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ 26 | use: { 27 | /* Base URL to use in actions like `await page.goto('/')`. */ 28 | baseURL: 'http://127.0.0.1:5017', 29 | 30 | /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ 31 | trace: 'on-first-retry', 32 | }, 33 | 34 | /* Configure projects for major browsers */ 35 | projects: [ 36 | { 37 | name: 'chromium', 38 | use: { ...devices['Desktop Chrome'] }, 39 | }, 40 | 41 | { 42 | name: 'firefox', 43 | use: { ...devices['Desktop Firefox'] }, 44 | }, 45 | 46 | { 47 | name: 'webkit', 48 | use: { ...devices['Desktop Safari'] }, 49 | }, 50 | 51 | /* Test against mobile viewports. */ 52 | // { 53 | // name: 'Mobile Chrome', 54 | // use: { ...devices['Pixel 5'] }, 55 | // }, 56 | // { 57 | // name: 'Mobile Safari', 58 | // use: { ...devices['iPhone 12'] }, 59 | // }, 60 | 61 | /* Test against branded browsers. */ 62 | // { 63 | // name: 'Microsoft Edge', 64 | // use: { ...devices['Desktop Edge'], channel: 'msedge' }, 65 | // }, 66 | // { 67 | // name: 'Google Chrome', 68 | // use: { ..devices['Desktop Chrome'], channel: 'chrome' }, 69 | // }, 70 | ], 71 | 72 | /* Run your local dev server before starting the tests */ 73 | // webServer: { 74 | // command: 'npm run start', 75 | // url: 'http://127.0.0.1:3000', 76 | // reuseExistingServer: !process.env.CI, 77 | // }, 78 | }); 79 | 80 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark the yarn lockfile as having been generated. 7 | yarn.lock linguist-generated 8 | 9 | # Mark any vendored files as having been vendored. 10 | vendor/* linguist-vendored 11 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | test/node_modules 3 | test/cypress.config.js 4 | test/playwright.config.js 5 | test/package.json 6 | test/yarn.lock 7 | test/cypress/ 8 | test/playwright/ 9 | test/playwright-report/ 10 | config/initializers/cypress_on_rails.rb 11 | vendor/bundle 12 | db/*.sqlite3 13 | db/schema.rb 14 | tmp/* 15 | log/* 16 | specs_e2e/server.pid 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' 5 | gem 'rails', '~> 6.1.7', '>= 6.1.7.10' 6 | # Use sqlite3 as the database for Active Record 7 | gem 'sqlite3', '~> 1.4' 8 | # Use Puma as the app server 9 | gem 'puma', '~> 5.0' 10 | 11 | # Reduces boot times through caching; required in config/boot.rb 12 | gem 'bootsnap', '>= 1.4.4', require: false 13 | gem 'concurrent-ruby', '< 1.3.5' 14 | gem 'date', '~> 3.3.3' 15 | gem 'timeout', '~> 0.3.2' 16 | 17 | group :development, :test do 18 | gem 'cypress-on-rails', path: '../../' 19 | gem 'database_cleaner' 20 | end 21 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_action :set_post, only: [:show, :edit, :update, :destroy] 3 | 4 | # GET /posts 5 | def index 6 | @posts = Post.all 7 | end 8 | 9 | # GET /posts/1 10 | def show 11 | end 12 | 13 | # GET /posts/new 14 | def new 15 | @post = Post.new 16 | end 17 | 18 | # GET /posts/1/edit 19 | def edit 20 | end 21 | 22 | # POST /posts 23 | def create 24 | @post = Post.new(post_params) 25 | 26 | if @post.save 27 | redirect_to @post, notice: 'Post was successfully created.' 28 | else 29 | render :new 30 | end 31 | end 32 | 33 | # PATCH/PUT /posts/1 34 | def update 35 | if @post.update(post_params) 36 | redirect_to @post, notice: 'Post was successfully updated.' 37 | else 38 | render :edit 39 | end 40 | end 41 | 42 | # DELETE /posts/1 43 | def destroy 44 | @post.destroy 45 | redirect_to posts_url, notice: 'Post was successfully destroyed.' 46 | end 47 | 48 | private 49 | # Use callbacks to share common setup or constraints between actions. 50 | def set_post 51 | @post = Post.find(params[:id]) 52 | end 53 | 54 | # Only allow a trusted parameter "white list" through. 55 | def post_params 56 | params.require(:post).permit(:title, :body, :published) 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/helpers/posts_helper.rb: -------------------------------------------------------------------------------- 1 | module PostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | App 5 | <%= csrf_meta_tags %> 6 | <%= csp_meta_tag %> 7 | 8 | 9 | 10 | <%= yield %> 11 | 12 | 13 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/posts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: post, local: true) do |form| %> 2 | <% if post.errors.any? %> 3 |
4 |

<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:

5 | 6 |
    7 | <% post.errors.full_messages.each do |message| %> 8 |
  • <%= message %>
  • 9 | <% end %> 10 |
11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :title %> 16 | <%= form.text_field :title %> 17 |
18 | 19 |
20 | <%= form.label :body %> 21 | <%= form.text_area :body %> 22 |
23 | 24 |
25 | <%= form.label :published %> 26 | <%= form.check_box :published %> 27 |
28 | 29 |
30 | <%= form.submit %> 31 |
32 | <% end %> 33 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/posts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Show', @post %> | 6 | <%= link_to 'Back', posts_path %> 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Posts

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <% @posts.each do |post| %> 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | <% end %> 26 | 27 |
TitleBodyPublished
<%= post.title %><%= post.body %><%= post.published %><%= link_to 'Show', post %><%= link_to 'Edit', edit_post_path(post) %><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
28 | 29 |
30 | 31 | <%= link_to 'New Post', new_post_path %> 32 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/posts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Back', posts_path %> 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Title: 5 | <%= @post.title %> 6 |

7 | 8 |

9 | Body: 10 | <%= @post.body %> 11 |

12 | 13 |

14 | Published: 15 | <%= @post.published %> 16 |

17 | 18 | <%= link_to 'Edit', edit_post_path(@post) %> | 19 | <%= link_to 'Back', posts_path %> 20 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../Gemfile", __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_requirement 64 | @bundler_requirement ||= 65 | env_var_version || cli_arg_version || 66 | bundler_requirement_for(lockfile_version) 67 | end 68 | 69 | def bundler_requirement_for(version) 70 | return "#{Gem::Requirement.default}.a" unless version 71 | 72 | bundler_gem_version = Gem::Version.new(version) 73 | 74 | requirement = bundler_gem_version.approximate_recommendation 75 | 76 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0") 77 | 78 | requirement += ".a" if bundler_gem_version.prerelease? 79 | 80 | requirement 81 | end 82 | 83 | def load_bundler! 84 | ENV["BUNDLE_GEMFILE"] ||= gemfile 85 | 86 | activate_bundler 87 | end 88 | 89 | def activate_bundler 90 | gem_error = activation_error_handling do 91 | gem "bundler", bundler_requirement 92 | end 93 | return if gem_error.nil? 94 | require_error = activation_error_handling do 95 | require "bundler/version" 96 | end 97 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 98 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 99 | exit 42 100 | end 101 | 102 | def activation_error_handling 103 | yield 104 | nil 105 | rescue StandardError, LoadError => e 106 | e 107 | end 108 | end 109 | 110 | m.load_bundler! 111 | 112 | if m.invoked_as_script? 113 | load Gem.bin_path("bundler", "bundle") 114 | end 115 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | load File.expand_path("spring", __dir__) 3 | APP_PATH = File.expand_path('../config/application', __dir__) 4 | require_relative "../config/boot" 5 | require "rails/commands" 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | load File.expand_path("spring", __dir__) 3 | require_relative "../config/boot" 4 | require "rake" 5 | Rake.application.run 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path('..', __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies 21 | system! 'bin/yarn' 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:prepare' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) 3 | gem "bundler" 4 | require "bundler" 5 | 6 | # Load Spring without loading other gems in the Gemfile, for speed. 7 | Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring| 8 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 9 | gem "spring", spring.version 10 | require "spring/binstub" 11 | rescue Gem::LoadError 12 | # Ignore when Spring is not installed. 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | yarn = ENV["PATH"].split(File::PATH_SEPARATOR). 5 | select { |dir| File.expand_path(dir) != __dir__ }. 6 | product(["yarn", "yarn.cmd", "yarn.ps1"]). 7 | map { |dir, file| File.expand_path(file, dir) }. 8 | find { |file| File.executable?(file) } 9 | 10 | if yarn 11 | exec yarn, *ARGV 12 | else 13 | $stderr.puts "Yarn executable was not detected in the system." 14 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 15 | exit 1 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'logger' 4 | require 'rails' 5 | # Pick the frameworks you want: 6 | require 'active_model/railtie' 7 | require 'active_job/railtie' 8 | require 'active_record/railtie' 9 | require 'active_storage/engine' 10 | require 'action_controller/railtie' 11 | require 'action_text/engine' 12 | require 'action_view/railtie' 13 | require 'action_cable/engine' 14 | # require "sprockets/railtie" 15 | # require "rails/test_unit/railtie" 16 | 17 | # Require the gems listed in Gemfile, including any gems 18 | # you've limited to :test, :development, or :production. 19 | Bundler.require(*Rails.groups) 20 | 21 | module App 22 | class Application < Rails::Application 23 | # Initialize configuration defaults for originally generated Rails version. 24 | config.load_defaults 6.1 25 | 26 | # Configuration for the application, engines, and railties goes here. 27 | # 28 | # These settings can be overridden in specific environments using the files 29 | # in config/environments, which are processed later. 30 | # 31 | # config.time_zone = "Central Time (US & Canada)" 32 | # config.eager_load_paths << Rails.root.join("extras") 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: app_production 11 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | XtTHzvHZqvH5arbcy28CkITjkhSQBOBwMZFJrrgvc3INakLJ5SBAfFeH9SdC/dQzBQ2v78cvrY7/xCsb2ELVwqp7Vhx20tPtsY1EZMz1f74m8FwYGlmq5GZI+uRVBv0rg7wNuvJPTry0L8HwpeM2gOpLlt85xe8sCMqzgugVxsysghW4FtQ3lx2zz48fsfnmnUN1iEKUvMyvBp9zTquiU2PkzoCPmckgymr8DNngKi6ArUOfzuVEgY0hKcL+ojk2kLImz1lQgMyC+691vo4AcT+X0yqt2O0SE5oOE8mx2HDZTMQ9GRjUl5Vm1CXsAiexKzyGR9J/4W82adD9TphlWJyBIM/FAndnqZDOBDCqZ0nvSNozcSccl3/LwFnkFhbHZXzpwkk5HpKzo91GZx8iha9+qITA6Yuz6k1B--j3HcmMwqzAV9IIBY--j4Il3ndJojPt4B3UvF1QWQ== -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | 8 | default: &default 9 | adapter: sqlite3 10 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 11 | timeout: 5000 12 | 13 | development: 14 | <<: *default 15 | database: db/development.sqlite3 16 | 17 | # Warning: The database defined as "test" will be erased and 18 | # re-generated from your development database when you run "rake". 19 | # Do not set this db to the same as development or production. 20 | test: 21 | <<: *default 22 | database: db/test.sqlite3 23 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/integer/time' 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable/disable caching. By default caching is disabled. 18 | # Run rails dev:cache to toggle caching. 19 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 20 | config.action_controller.perform_caching = true 21 | config.action_controller.enable_fragment_cache_logging = true 22 | 23 | config.cache_store = :memory_store 24 | config.public_file_server.headers = { 25 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 26 | } 27 | else 28 | config.action_controller.perform_caching = false 29 | 30 | config.cache_store = :null_store 31 | end 32 | 33 | # Store uploaded files on the local file system (see config/storage.yml for options). 34 | config.active_storage.service = :local 35 | 36 | # Print deprecation notices to the Rails logger. 37 | config.active_support.deprecation = :log 38 | 39 | # Raise exceptions for disallowed deprecations. 40 | config.active_support.disallowed_deprecation = :raise 41 | 42 | # Tell Active Support which deprecation messages to disallow. 43 | config.active_support.disallowed_deprecation_warnings = [] 44 | 45 | # Raise an error on page load if there are pending migrations. 46 | config.active_record.migration_error = :page_load 47 | 48 | # Highlight code that triggered database queries in logs. 49 | config.active_record.verbose_query_logs = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | 55 | # Uncomment if you wish to allow Action Cable access from any origin. 56 | # config.action_cable.disable_request_forgery_protection = true 57 | end 58 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | config.cache_classes = false 12 | config.action_view.cache_template_loading = true 13 | 14 | # Do not eager load code on boot. This avoids loading your whole application 15 | # just for the purpose of running a single test. If you are using a tool that 16 | # preloads Rails for running tests, you may have to set it to true. 17 | config.eager_load = false 18 | 19 | # Configure public file server for tests with Cache-Control for performance. 20 | config.public_file_server.enabled = true 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 23 | } 24 | 25 | # Show full error reports and disable caching. 26 | config.consider_all_requests_local = true 27 | config.action_controller.perform_caching = false 28 | config.cache_store = :null_store 29 | 30 | # Raise exceptions instead of rendering exception templates. 31 | config.action_dispatch.show_exceptions = false 32 | 33 | # Disable request forgery protection in test environment. 34 | config.action_controller.allow_forgery_protection = false 35 | 36 | # Store uploaded files on the local file system in a temporary directory. 37 | config.active_storage.service = :test 38 | 39 | # Print deprecation notices to the stderr. 40 | config.active_support.deprecation = :stderr 41 | 42 | # Raise exceptions for disallowed deprecations. 43 | config.active_support.disallowed_deprecation = :raise 44 | 45 | # Tell Active Support which deprecation messages to disallow. 46 | config.active_support.disallowed_deprecation_warnings = [] 47 | 48 | # Raises error for missing translations. 49 | # config.i18n.raise_on_missing_translations = true 50 | 51 | # Annotate rendered view with file names. 52 | # config.action_view.annotate_rendered_view_with_filenames = true 53 | end 54 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code 7 | # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". 8 | Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | # # If you are using webpack-dev-server then specify webpack-dev-server host 15 | # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? 16 | 17 | # # Specify URI for violation reports 18 | # # policy.report_uri "/csp-violation-report-endpoint" 19 | # end 20 | 21 | # If you are using UJS then enable automatic nonce generation 22 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 23 | 24 | # Set the nonce only to specific directives 25 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) 26 | 27 | # Report CSP violations to a specified URI 28 | # For further information see the following documentation: 29 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 30 | # Rails.application.config.content_security_policy_report_only = true 31 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [ 5 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 6 | ] 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Define an application-wide HTTP permissions policy. For further 2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy 3 | # 4 | # Rails.application.config.permissions_policy do |f| 5 | # f.camera :none 6 | # f.gyroscope :none 7 | # f.microphone :none 8 | # f.usb :none 9 | # f.fullscreen :self 10 | # f.payment :self, "https://secure.example.com" 11 | # end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/master.key: -------------------------------------------------------------------------------- 1 | d4410d4dc7e27ed1b7657c233947edd6 -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 12 | # terminating a worker in development environments. 13 | # 14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 15 | 16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 17 | # 18 | port ENV.fetch("PORT") { 3000 } 19 | 20 | # Specifies the `environment` that Puma will run in. 21 | # 22 | environment ENV.fetch("RAILS_ENV") { "development" } 23 | 24 | # Specifies the `pidfile` that Puma will use. 25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 26 | 27 | # Specifies the number of `workers` to boot in clustered mode. 28 | # Workers are forked web server processes. If using threads and workers together 29 | # the concurrency of the application would be max `threads` * `workers`. 30 | # Workers do not work on JRuby or Windows (both of which do not support 31 | # processes). 32 | # 33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 34 | 35 | # Use the `preload_app!` method when specifying a `workers` number. 36 | # This directive tells Puma to first boot the application and load code 37 | # before forking the application. This takes advantage of Copy On Write 38 | # process behavior so workers use less memory. 39 | # 40 | # preload_app! 41 | 42 | # Allow puma to be restarted by `rails restart` command. 43 | plugin :tmp_restart 44 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :posts 3 | root 'posts#index' 4 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 5 | end 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/db/migrate/20180621085832_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration[6.1] 2 | def change 3 | create_table :posts do |t| 4 | t.string :title 5 | t.text :body 6 | t.boolean :published 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@playwright/test": "^1.49.1", 4 | "cypress": "^13.17.0", 5 | "cypress-on-rails": "^0.1.0", 6 | "playwright": "^1.49.1" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_6_1/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_6_1/public/apple-touch-icon.png -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_6_1/public/favicon.ico -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test-results/.last-run.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "passed", 3 | "failedTests": [] 4 | } -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | echo '--- testing rails 6.1.7' 5 | 6 | echo '-- setting environment' 7 | export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | export RAILS_ENV=test 9 | export BUNDLE_GEMFILE="$DIR/Gemfile" 10 | cd $DIR 11 | 12 | echo '-- bundle install' 13 | bundle --version 14 | bundle config set --local path 'vendor/bundle' 15 | bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 16 | 17 | echo '-- migration' 18 | bundle exec ./bin/rails db:drop || true 19 | bundle exec ./bin/rails db:create db:migrate 20 | 21 | echo '-- cypress install' 22 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework cypress --install_with=npm --force 23 | rm -vf test/cypress/e2e/rails_examples/using_vcr.cy.js 24 | 25 | echo '-- start rails server' 26 | # make sure the server is not running 27 | (kill -9 `cat ../server.pid` || true ) 28 | 29 | bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & 30 | sleep 2 # give rails a chance to start up correctly 31 | 32 | echo '-- cypress run' 33 | cp -fv ../cypress.config.js test/ 34 | cd test 35 | npx cypress install 36 | # if [ -z $CYPRESS_RECORD_KEY ] 37 | # then 38 | # npx cypress run 39 | # else 40 | npx cypress run # --record 41 | # fi 42 | 43 | echo '-- playwright install' 44 | cd .. 45 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework playwright --install_with=npm --force 46 | rm -vf test/playwright/e2e/rails_examples/using_vcr.cy.js 47 | 48 | echo '-- playwright run' 49 | cd test 50 | cp -fv ../../playwright.config.js . 51 | npx playwright install-deps 52 | npx playwright install 53 | npx playwright test test/playwright 54 | # npx playwright show-report 55 | 56 | echo '-- stop rails server' 57 | kill -9 `cat ../../server.pid` || true 58 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test/controllers/posts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @post = posts(:one) 6 | end 7 | 8 | test "should get index" do 9 | get posts_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_post_url 15 | assert_response :success 16 | end 17 | 18 | test "should create post" do 19 | assert_difference('Post.count') do 20 | post posts_url, params: { post: { body: @post.body, published: @post.published, title: @post.title } } 21 | end 22 | 23 | assert_redirected_to post_url(Post.last) 24 | end 25 | 26 | test "should show post" do 27 | get post_url(@post) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_post_url(@post) 33 | assert_response :success 34 | end 35 | 36 | test "should update post" do 37 | patch post_url(@post), params: { post: { body: @post.body, published: @post.published, title: @post.title } } 38 | assert_redirected_to post_url(@post) 39 | end 40 | 41 | test "should destroy post" do 42 | assert_difference('Post.count', -1) do 43 | delete post_url(@post) 44 | end 45 | 46 | assert_redirected_to posts_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test/cypress_fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyCypressFixtures 5 | body: MyText 6 | published: true 7 | 8 | two: 9 | title: MyCypressFixtures2 10 | body: MyText 11 | published: true 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyRailsFixtures 5 | body: MyText 6 | published: false 7 | 8 | two: 9 | title: MyRailsFixtures2 10 | body: MyText 11 | published: false 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/test/models/post_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_6_1/vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_6_1/vendor/.keep -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | config/credentials/*.yml.enc diff=rails_credentials 9 | config/credentials.yml.enc diff=rails_credentials 10 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | test/node_modules 3 | test/cypress.config.js 4 | test/playwright.config.js 5 | test/package.json 6 | test/yarn.lock 7 | test/cypress/ 8 | test/playwright/ 9 | test/playwright-report/ 10 | config/initializers/cypress_on_rails.rb 11 | vendor/bundle 12 | db/*.sqlite3 13 | db/schema.rb 14 | tmp/* 15 | log/* 16 | specs_e2e/server.pid 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Omakase Ruby styling for Rails 2 | inherit_gem: { rubocop-rails-omakase: rubocop.yml } 3 | 4 | # Overwrite or add rules to create your own house style 5 | # 6 | # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` 7 | # Layout/SpaceInsideArrayLiteralBrackets: 8 | # Enabled: false 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rails", "~> 7.2.2" 4 | gem "sqlite3", ">= 1.4" 5 | gem "puma", ">= 5.0" 6 | gem "bootsnap", require: false 7 | 8 | group :development, :test do 9 | gem 'cypress-on-rails', path: '../../' 10 | gem 'database_cleaner' 11 | end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. 3 | allow_browser versions: :modern 4 | end 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_action :set_post, only: [:show, :edit, :update, :destroy] 3 | 4 | # GET /posts 5 | def index 6 | @posts = Post.all 7 | end 8 | 9 | # GET /posts/1 10 | def show 11 | end 12 | 13 | # GET /posts/new 14 | def new 15 | @post = Post.new 16 | end 17 | 18 | # GET /posts/1/edit 19 | def edit 20 | end 21 | 22 | # POST /posts 23 | def create 24 | @post = Post.new(post_params) 25 | 26 | if @post.save 27 | redirect_to @post, notice: 'Post was successfully created.' 28 | else 29 | render :new 30 | end 31 | end 32 | 33 | # PATCH/PUT /posts/1 34 | def update 35 | if @post.update(post_params) 36 | redirect_to @post, notice: 'Post was successfully updated.' 37 | else 38 | render :edit 39 | end 40 | end 41 | 42 | # DELETE /posts/1 43 | def destroy 44 | @post.destroy 45 | redirect_to posts_url, notice: 'Post was successfully destroyed.' 46 | end 47 | 48 | private 49 | # Use callbacks to share common setup or constraints between actions. 50 | def set_post 51 | @post = Post.find(params[:id]) 52 | end 53 | 54 | # Only allow a trusted parameter "white list" through. 55 | def post_params 56 | params.require(:post).permit(:title, :body, :published) 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/helpers/posts_helper.rb: -------------------------------------------------------------------------------- 1 | module PostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= content_for(:title) || "App" %> 5 | 6 | 7 | <%= csrf_meta_tags %> 8 | <%= csp_meta_tag %> 9 | 10 | <%= yield :head %> 11 | 12 | 13 | 14 | 15 | 16 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> 17 | 18 | 19 | 20 | <%= yield %> 21 | 22 | 23 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/posts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: post, local: true) do |form| %> 2 | <% if post.errors.any? %> 3 |
4 |

<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:

5 | 6 |
    7 | <% post.errors.full_messages.each do |message| %> 8 |
  • <%= message %>
  • 9 | <% end %> 10 |
11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :title %> 16 | <%= form.text_field :title %> 17 |
18 | 19 |
20 | <%= form.label :body %> 21 | <%= form.text_area :body %> 22 |
23 | 24 |
25 | <%= form.label :published %> 26 | <%= form.check_box :published %> 27 |
28 | 29 |
30 | <%= form.submit %> 31 |
32 | <% end %> 33 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/posts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Show', @post %> | 6 | <%= link_to 'Back', posts_path %> 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Posts

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <% @posts.each do |post| %> 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | <% end %> 26 | 27 |
TitleBodyPublished
<%= post.title %><%= post.body %><%= post.published %><%= link_to 'Show', post %><%= link_to 'Edit', edit_post_path(post) %><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
28 | 29 |
30 | 31 | <%= link_to 'New Post', new_post_path %> 32 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/posts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Back', posts_path %> 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Title: 5 | <%= @post.title %> 6 |

7 | 8 |

9 | Body: 10 | <%= @post.body %> 11 |

12 | 13 |

14 | Published: 15 | <%= @post.published %> 16 |

17 | 18 | <%= link_to 'Edit', edit_post_path(@post) %> | 19 | <%= link_to 'Back', posts_path %> 20 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/brakeman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "bundler/setup" 4 | 5 | ARGV.unshift("--ensure-latest") 6 | 7 | load Gem.bin_path("brakeman", "brakeman") 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../Gemfile", __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_requirement 64 | @bundler_requirement ||= 65 | env_var_version || 66 | cli_arg_version || 67 | bundler_requirement_for(lockfile_version) 68 | end 69 | 70 | def bundler_requirement_for(version) 71 | return "#{Gem::Requirement.default}.a" unless version 72 | 73 | bundler_gem_version = Gem::Version.new(version) 74 | 75 | bundler_gem_version.approximate_recommendation 76 | end 77 | 78 | def load_bundler! 79 | ENV["BUNDLE_GEMFILE"] ||= gemfile 80 | 81 | activate_bundler 82 | end 83 | 84 | def activate_bundler 85 | gem_error = activation_error_handling do 86 | gem "bundler", bundler_requirement 87 | end 88 | return if gem_error.nil? 89 | require_error = activation_error_handling do 90 | require "bundler/version" 91 | end 92 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 93 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 94 | exit 42 95 | end 96 | 97 | def activation_error_handling 98 | yield 99 | nil 100 | rescue StandardError, LoadError => e 101 | e 102 | end 103 | end 104 | 105 | m.load_bundler! 106 | 107 | if m.invoked_as_script? 108 | load Gem.bin_path("bundler", "bundle") 109 | end 110 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "../config/application" 4 | require "importmap/commands" 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | APP_ROOT = File.expand_path("..", __dir__) 5 | APP_NAME = "app" 6 | 7 | def system!(*args) 8 | system(*args, exception: true) 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | 34 | # puts "\n== Configuring puma-dev ==" 35 | # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" 36 | # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" 37 | end 38 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require 'logger' 4 | require 'rails' 5 | # Pick the frameworks you want: 6 | require 'active_model/railtie' 7 | require 'active_job/railtie' 8 | require 'active_record/railtie' 9 | require 'active_storage/engine' 10 | require 'action_controller/railtie' 11 | require 'action_text/engine' 12 | require 'action_view/railtie' 13 | require 'action_cable/engine' 14 | 15 | # Require the gems listed in Gemfile, including any gems 16 | # you've limited to :test, :development, or :production. 17 | Bundler.require(*Rails.groups) 18 | 19 | module App 20 | class Application < Rails::Application 21 | # Initialize configuration defaults for originally generated Rails version. 22 | config.load_defaults 7.2 23 | 24 | # Please, add to the `ignore` list any other `lib` subdirectories that do 25 | # not contain `.rb` files, or that should not be reloaded or eager loaded. 26 | # Common ones are `templates`, `generators`, or `middleware`, for example. 27 | config.autoload_lib(ignore: %w[assets tasks]) 28 | 29 | # Configuration for the application, engines, and railties goes here. 30 | # 31 | # These settings can be overridden in specific environments using the files 32 | # in config/environments, which are processed later. 33 | # 34 | # config.time_zone = "Central Time (US & Canada)" 35 | # config.eager_load_paths << Rails.root.join("extras") 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: app_production 11 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | oh98nG3RVyvWel7DHqGddaOy5TmoEiIXCIGfOzYwUIQCFsuRCjPXjhyPUpC/tk2vFxYla7+v1KjMTrPn7lf1/FCwq0iY/bHKUVuOhkBgS8rg0ovhVnUq92HYwmWKPHsQgDrRQRoGgZzsFs6tCgl8oKTJ6bwy6GnaYU/a020vqqd0TOOJViDWqo+hEy+ZmhZROJcEJ5swjTq2tZtJIkkXT0n9ug/ezKXxu2f9ABZS7UexaQuc7ILOnHv1TZ0zTwVS5vDV5zm48315jZpwq86jK1i8fsgzjf3r9W1YumNMT4W/uKef5UJGbmS/okaSgA8DF37vyUi7nlcFtXuJrMHJThBpjV1eB+A3fMzCAAAxM9/oNfUQddbPjVlIk/9lb1R/5cBe0oz7QyemzpKx0FWfVncPlJd7--lRNQXXXdHpDiWyxY--uRorsjITTUQAzA1y/d9NZA== -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem "sqlite3" 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | 24 | # SQLite3 write its data on the local filesystem, as such it requires 25 | # persistent disks. If you are deploying to a managed service, you should 26 | # make sure it provides disk persistence, as many don't. 27 | # 28 | # Similarly, if you deploy your application as a Docker container, you must 29 | # ensure the database is located in a persisted volume. 30 | production: 31 | <<: *default 32 | # database: path/to/persistent/storage/production.sqlite3 33 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.enable_reloading = true 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable server timing. 18 | config.server_timing = true 19 | 20 | # Enable/disable caching. By default caching is disabled. 21 | # Run rails dev:cache to toggle caching. 22 | if Rails.root.join("tmp/caching-dev.txt").exist? 23 | config.action_controller.perform_caching = true 24 | config.action_controller.enable_fragment_cache_logging = true 25 | 26 | config.cache_store = :memory_store 27 | config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } 28 | else 29 | config.action_controller.perform_caching = false 30 | 31 | config.cache_store = :null_store 32 | end 33 | 34 | # Store uploaded files on the local file system (see config/storage.yml for options). 35 | config.active_storage.service = :local 36 | 37 | # Print deprecation notices to the Rails logger. 38 | config.active_support.deprecation = :log 39 | 40 | # Raise exceptions for disallowed deprecations. 41 | config.active_support.disallowed_deprecation = :raise 42 | 43 | # Tell Active Support which deprecation messages to disallow. 44 | config.active_support.disallowed_deprecation_warnings = [] 45 | 46 | # Raise an error on page load if there are pending migrations. 47 | config.active_record.migration_error = :page_load 48 | 49 | # Highlight code that triggered database queries in logs. 50 | config.active_record.verbose_query_logs = true 51 | 52 | # Highlight code that enqueued background job in logs. 53 | config.active_job.verbose_enqueue_logs = true 54 | end 55 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # While tests run files are not watched, reloading is not necessary. 12 | config.enable_reloading = false 13 | 14 | # Eager loading loads your entire application. When running a single test locally, 15 | # this is usually not necessary, and can slow down your test suite. However, it's 16 | # recommended that you enable it in continuous integration systems to ensure eager 17 | # loading is working properly before deploying your code. 18 | config.eager_load = ENV["CI"].present? 19 | 20 | # Configure public file server for tests with Cache-Control for performance. 21 | config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } 22 | 23 | # Show full error reports and disable caching. 24 | config.consider_all_requests_local = true 25 | config.action_controller.perform_caching = false 26 | config.cache_store = :null_store 27 | 28 | # Render exception templates for rescuable exceptions and raise for other exceptions. 29 | config.action_dispatch.show_exceptions = :rescuable 30 | 31 | # Disable request forgery protection in test environment. 32 | config.action_controller.allow_forgery_protection = false 33 | 34 | # Store uploaded files on the local file system in a temporary directory. 35 | config.active_storage.service = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raise exceptions for disallowed deprecations. 41 | config.active_support.disallowed_deprecation = :raise 42 | 43 | # Tell Active Support which deprecation messages to disallow. 44 | config.active_support.disallowed_deprecation_warnings = [] 45 | end 46 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/importmap.rb: -------------------------------------------------------------------------------- 1 | # Pin npm packages by running ./bin/importmap 2 | 3 | pin "application" 4 | pin "@hotwired/turbo-rails", to: "turbo.min.js" 5 | pin "@hotwired/stimulus", to: "stimulus.min.js" 6 | pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" 7 | pin_all_from "app/javascript/controllers", under: "controllers" 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap, inline scripts, and inline styles. 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src style-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. 4 | # Use this to limit dissemination of sensitive information. 5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide HTTP permissions policy. For further 4 | # information see: https://developers.google.com/web/updates/2018/06/feature-policy 5 | 6 | # Rails.application.config.permissions_policy do |policy| 7 | # policy.camera :none 8 | # policy.gyroscope :none 9 | # policy.microphone :none 10 | # policy.usb :none 11 | # policy.fullscreen :self 12 | # policy.payment :self, "https://secure.example.com" 13 | # end 14 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization and 2 | # are automatically loaded by Rails. If you want to use locales other than 3 | # English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more about the API, please read the Rails Internationalization guide 20 | # at https://guides.rubyonrails.org/i18n.html. 21 | # 22 | # Be aware that YAML interprets the following case-insensitive strings as 23 | # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings 24 | # must be quoted to be interpreted as strings. For example: 25 | # 26 | # en: 27 | # "yes": yup 28 | # enabled: "ON" 29 | 30 | en: 31 | hello: "Hello world" 32 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/master.key: -------------------------------------------------------------------------------- 1 | 5b6ca964fe3f4c95d39f82330b15718d -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/puma.rb: -------------------------------------------------------------------------------- 1 | # This configuration file will be evaluated by Puma. The top-level methods that 2 | # are invoked here are part of Puma's configuration DSL. For more information 3 | # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. 4 | 5 | # Puma starts a configurable number of processes (workers) and each process 6 | # serves each request in a thread from an internal thread pool. 7 | # 8 | # The ideal number of threads per worker depends both on how much time the 9 | # application spends waiting for IO operations and on how much you wish to 10 | # to prioritize throughput over latency. 11 | # 12 | # As a rule of thumb, increasing the number of threads will increase how much 13 | # traffic a given process can handle (throughput), but due to CRuby's 14 | # Global VM Lock (GVL) it has diminishing returns and will degrade the 15 | # response time (latency) of the application. 16 | # 17 | # The default is set to 3 threads as it's deemed a decent compromise between 18 | # throughput and latency for the average Rails application. 19 | # 20 | # Any libraries that use a connection pool or another resource pool should 21 | # be configured to provide at least as many connections as the number of 22 | # threads. This includes Active Record's `pool` parameter in `database.yml`. 23 | threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) 24 | threads threads_count, threads_count 25 | 26 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 27 | port ENV.fetch("PORT", 3000) 28 | 29 | # Allow puma to be restarted by `bin/rails restart` command. 30 | plugin :tmp_restart 31 | 32 | # Specify the PID file. Defaults to tmp/pids/server.pid in development. 33 | # In other environments, only set the PID file if requested. 34 | pidfile ENV["PIDFILE"] if ENV["PIDFILE"] 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :posts 3 | root 'posts#index' 4 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 5 | end 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/db/migrate/20180621085832_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration[7.2] 2 | def change 3 | create_table :posts do |t| 4 | t.string :title 5 | t.text :body 6 | t.boolean :published 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should ensure the existence of records required to run the application in every environment (production, 2 | # development, test). The code here should be idempotent so that it can be executed at any point in every environment. 3 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 | # 5 | # Example: 6 | # 7 | # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| 8 | # MovieGenre.find_or_create_by!(name: genre_name) 9 | # end 10 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/db/test.sqlite3-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/db/test.sqlite3-shm -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/db/test.sqlite3-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/db/test.sqlite3-wal -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@playwright/test": "^1.50.0", 4 | "cypress": "^14.0.0", 5 | "cypress-on-rails": "^0.1.0", 6 | "playwright": "^1.50.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/406-unsupported-browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Your browser is not supported (406) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

Your browser is not supported.

62 |

Please upgrade your browser to continue.

63 |
64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/public/icon.png -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/storage/test.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/storage/test.sqlite3 -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test-results/.last-run.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "passed", 3 | "failedTests": [] 4 | } -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | echo '--- testing rails 7.2.2' 5 | 6 | echo '-- setting environment' 7 | export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | export RAILS_ENV=test 9 | export BUNDLE_GEMFILE="$DIR/Gemfile" 10 | cd $DIR 11 | 12 | echo '-- bundle install' 13 | bundle --version 14 | bundle config set --local path 'vendor/bundle' 15 | bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 16 | 17 | echo '-- migration' 18 | bundle exec ./bin/rails db:drop || true 19 | bundle exec ./bin/rails db:create db:migrate 20 | 21 | echo '-- cypress install' 22 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework cypress --install_with=npm --force 23 | rm -vf test/cypress/e2e/rails_examples/using_vcr.cy.js 24 | 25 | echo '-- start rails server' 26 | # make sure the server is not running 27 | (kill -9 `cat ../server.pid` || true ) 28 | 29 | bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & 30 | sleep 2 # give rails a chance to start up correctly 31 | 32 | echo '-- cypress run' 33 | cp -fv ../cypress.config.js test/ 34 | cd test 35 | npx cypress install 36 | # if [ -z $CYPRESS_RECORD_KEY ] 37 | # then 38 | # npx cypress run 39 | # else 40 | npx cypress run # --record 41 | # fi 42 | 43 | echo '-- playwright install' 44 | cd .. 45 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework playwright --install_with=npm --force 46 | rm -vf test/playwright/e2e/rails_examples/using_vcr.cy.js 47 | 48 | echo '-- playwright run' 49 | cd test 50 | cp -fv ../../playwright.config.js . 51 | npx playwright install-deps 52 | npx playwright install 53 | npx playwright test test/playwright 54 | # npx playwright show-report 55 | 56 | echo '-- stop rails server' 57 | kill -9 `cat ../../server.pid` || true 58 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test/controllers/posts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @post = posts(:one) 6 | end 7 | 8 | test "should get index" do 9 | get posts_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_post_url 15 | assert_response :success 16 | end 17 | 18 | test "should create post" do 19 | assert_difference('Post.count') do 20 | post posts_url, params: { post: { body: @post.body, published: @post.published, title: @post.title } } 21 | end 22 | 23 | assert_redirected_to post_url(Post.last) 24 | end 25 | 26 | test "should show post" do 27 | get post_url(@post) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_post_url(@post) 33 | assert_response :success 34 | end 35 | 36 | test "should update post" do 37 | patch post_url(@post), params: { post: { body: @post.body, published: @post.published, title: @post.title } } 38 | assert_redirected_to post_url(@post) 39 | end 40 | 41 | test "should destroy post" do 42 | assert_difference('Post.count', -1) do 43 | delete post_url(@post) 44 | end 45 | 46 | assert_redirected_to posts_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test/cypress_fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyCypressFixtures 5 | body: MyText 6 | published: true 7 | 8 | two: 9 | title: MyCypressFixtures2 10 | body: MyText 11 | published: true 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyRailsFixtures 5 | body: MyText 6 | published: false 7 | 8 | two: 9 | title: MyRailsFixtures2 10 | body: MyText 11 | published: false 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/test/models/post_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/vendor/.keep -------------------------------------------------------------------------------- /specs_e2e/rails_7_2/vendor/javascript/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_7_2/vendor/javascript/.keep -------------------------------------------------------------------------------- /specs_e2e/rails_8/.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | config/credentials/*.yml.enc diff=rails_credentials 9 | config/credentials.yml.enc diff=rails_credentials 10 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | test/node_modules 3 | test/cypress.config.js 4 | test/playwright.config.js 5 | test/package.json 6 | test/yarn.lock 7 | test/cypress/ 8 | test/playwright/ 9 | test/playwright-report/ 10 | config/initializers/cypress_on_rails.rb 11 | vendor/bundle 12 | db/*.sqlite3 13 | db/schema.rb 14 | tmp/* 15 | log/* 16 | specs_e2e/server.pid 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Omakase Ruby styling for Rails 2 | inherit_gem: { rubocop-rails-omakase: rubocop.yml } 3 | 4 | # Overwrite or add rules to create your own house style 5 | # 6 | # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` 7 | # Layout/SpaceInsideArrayLiteralBrackets: 8 | # Enabled: false 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 4 | gem "rails", "~> 8.0.1" 5 | # The modern asset pipeline for Rails [https://github.com/rails/propshaft] 6 | gem "propshaft" 7 | # Use sqlite3 as the database for Active Record 8 | gem "sqlite3", ">= 2.1" 9 | # Use the Puma web server [https://github.com/puma/puma] 10 | gem "puma", ">= 5.0" 11 | # Reduces boot times through caching; required in config/boot.rb 12 | gem "bootsnap", require: false 13 | 14 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 15 | # gem "image_processing", "~> 1.2" 16 | 17 | group :development, :test do 18 | gem 'cypress-on-rails', path: '../../' 19 | gem 'database_cleaner' 20 | end 21 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css. 3 | * 4 | * With Propshaft, assets are served efficiently without preprocessing steps. You can still include 5 | * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard 6 | * cascading order, meaning styles declared later in the document or manifest will override earlier ones, 7 | * depending on specificity. 8 | * 9 | * Consider organizing styles into separate files for maintainability. 10 | */ 11 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. 3 | allow_browser versions: :modern 4 | end 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_action :set_post, only: [:show, :edit, :update, :destroy] 3 | 4 | # GET /posts 5 | def index 6 | @posts = Post.all 7 | end 8 | 9 | # GET /posts/1 10 | def show 11 | end 12 | 13 | # GET /posts/new 14 | def new 15 | @post = Post.new 16 | end 17 | 18 | # GET /posts/1/edit 19 | def edit 20 | end 21 | 22 | # POST /posts 23 | def create 24 | @post = Post.new(post_params) 25 | 26 | if @post.save 27 | redirect_to @post, notice: 'Post was successfully created.' 28 | else 29 | render :new 30 | end 31 | end 32 | 33 | # PATCH/PUT /posts/1 34 | def update 35 | if @post.update(post_params) 36 | redirect_to @post, notice: 'Post was successfully updated.' 37 | else 38 | render :edit 39 | end 40 | end 41 | 42 | # DELETE /posts/1 43 | def destroy 44 | @post.destroy 45 | redirect_to posts_url, notice: 'Post was successfully destroyed.' 46 | end 47 | 48 | private 49 | # Use callbacks to share common setup or constraints between actions. 50 | def set_post 51 | @post = Post.find(params[:id]) 52 | end 53 | 54 | # Only allow a trusted parameter "white list" through. 55 | def post_params 56 | params.require(:post).permit(:title, :body, :published) 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/helpers/posts_helper.rb: -------------------------------------------------------------------------------- 1 | module PostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= content_for(:title) || "App" %> 5 | 6 | 7 | 8 | <%= csrf_meta_tags %> 9 | <%= csp_meta_tag %> 10 | 11 | <%= yield :head %> 12 | 13 | <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> 14 | <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> 15 | 16 | 17 | 18 | 19 | 20 | <%# Includes all stylesheet files in app/assets/stylesheets %> 21 | <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> 22 | 23 | 24 | 25 | <%= yield %> 26 | 27 | 28 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/posts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: post, local: true) do |form| %> 2 | <% if post.errors.any? %> 3 |
4 |

<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:

5 | 6 |
    7 | <% post.errors.full_messages.each do |message| %> 8 |
  • <%= message %>
  • 9 | <% end %> 10 |
11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :title %> 16 | <%= form.text_field :title %> 17 |
18 | 19 |
20 | <%= form.label :body %> 21 | <%= form.text_area :body %> 22 |
23 | 24 |
25 | <%= form.label :published %> 26 | <%= form.check_box :published %> 27 |
28 | 29 |
30 | <%= form.submit %> 31 |
32 | <% end %> 33 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/posts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Show', @post %> | 6 | <%= link_to 'Back', posts_path %> 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Posts

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <% @posts.each do |post| %> 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | <% end %> 26 | 27 |
TitleBodyPublished
<%= post.title %><%= post.body %><%= post.published %><%= link_to 'Show', post %><%= link_to 'Edit', edit_post_path(post) %><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
28 | 29 |
30 | 31 | <%= link_to 'New Post', new_post_path %> 32 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/posts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New Post

2 | 3 | <%= render 'form', post: @post %> 4 | 5 | <%= link_to 'Back', posts_path %> 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Title: 5 | <%= @post.title %> 6 |

7 | 8 |

9 | Body: 10 | <%= @post.body %> 11 |

12 | 13 |

14 | Published: 15 | <%= @post.published %> 16 |

17 | 18 | <%= link_to 'Edit', edit_post_path(@post) %> | 19 | <%= link_to 'Back', posts_path %> 20 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/brakeman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "bundler/setup" 4 | 5 | ARGV.unshift("--ensure-latest") 6 | 7 | load Gem.bin_path("brakeman", "brakeman") 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../Gemfile", __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_requirement 64 | @bundler_requirement ||= 65 | env_var_version || 66 | cli_arg_version || 67 | bundler_requirement_for(lockfile_version) 68 | end 69 | 70 | def bundler_requirement_for(version) 71 | return "#{Gem::Requirement.default}.a" unless version 72 | 73 | bundler_gem_version = Gem::Version.new(version) 74 | 75 | bundler_gem_version.approximate_recommendation 76 | end 77 | 78 | def load_bundler! 79 | ENV["BUNDLE_GEMFILE"] ||= gemfile 80 | 81 | activate_bundler 82 | end 83 | 84 | def activate_bundler 85 | gem_error = activation_error_handling do 86 | gem "bundler", bundler_requirement 87 | end 88 | return if gem_error.nil? 89 | require_error = activation_error_handling do 90 | require "bundler/version" 91 | end 92 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 93 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 94 | exit 42 95 | end 96 | 97 | def activation_error_handling 98 | yield 99 | nil 100 | rescue StandardError, LoadError => e 101 | e 102 | end 103 | end 104 | 105 | m.load_bundler! 106 | 107 | if m.invoked_as_script? 108 | load Gem.bin_path("bundler", "bundle") 109 | end 110 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | exec "./bin/rails", "server", *ARGV 3 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "../config/application" 4 | require "importmap/commands" 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | APP_ROOT = File.expand_path("..", __dir__) 5 | 6 | def system!(*args) 7 | system(*args, exception: true) 8 | end 9 | 10 | FileUtils.chdir APP_ROOT do 11 | # This script is a way to set up or update your development environment automatically. 12 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 13 | # Add necessary setup steps to this file. 14 | 15 | puts "== Installing dependencies ==" 16 | system("bundle check") || system!("bundle install") 17 | 18 | # puts "\n== Copying sample files ==" 19 | # unless File.exist?("config/database.yml") 20 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 21 | # end 22 | 23 | puts "\n== Preparing database ==" 24 | system! "bin/rails db:prepare" 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! "bin/rails log:clear tmp:clear" 28 | 29 | unless ARGV.include?("--skip-server") 30 | puts "\n== Starting development server ==" 31 | STDOUT.flush # flush the output before exec(2) so that it displays 32 | exec "bin/dev" 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/bin/thrust: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "bundler/setup" 4 | 5 | load Gem.bin_path("thruster", "thrust") 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module App 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 8.0 13 | 14 | # Please, add to the `ignore` list any other `lib` subdirectories that do 15 | # not contain `.rb` files, or that should not be reloaded or eager loaded. 16 | # Common ones are `templates`, `generators`, or `middleware`, for example. 17 | config.autoload_lib(ignore: %w[assets tasks]) 18 | 19 | # Configuration for the application, engines, and railties goes here. 20 | # 21 | # These settings can be overridden in specific environments using the files 22 | # in config/environments, which are processed later. 23 | # 24 | # config.time_zone = "Central Time (US & Canada)" 25 | # config.eager_load_paths << Rails.root.join("extras") 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/cable.yml: -------------------------------------------------------------------------------- 1 | # Async adapter only works within the same process, so for manually triggering cable updates from a console, 2 | # and seeing results in the browser, you must do so from the web console (running inside the dev process), 3 | # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view 4 | # to make the web console appear. 5 | development: 6 | adapter: async 7 | 8 | test: 9 | adapter: test 10 | 11 | production: 12 | adapter: solid_cable 13 | connects_to: 14 | database: 15 | writing: cable 16 | polling_interval: 0.1.seconds 17 | message_retention: 1.day 18 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/cache.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | store_options: 3 | # Cap age of oldest cache entry to fulfill retention policies 4 | # max_age: <%= 60.days.to_i %> 5 | max_size: <%= 256.megabytes %> 6 | namespace: <%= Rails.env %> 7 | 8 | development: 9 | <<: *default 10 | 11 | test: 12 | <<: *default 13 | 14 | production: 15 | database: cache 16 | <<: *default 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | KBXR054/drP12hr3yMGD6qBrGNOk57kGD467ieoFiMsBRCB1xp5g9JYRDGruQmSYFgchTPmkCnemgpvYtnoL9x3I8JNlsmLP6fONg4jn6srirYy93BBDTu8i3GMWGbbXmYHcmix6GIy4of9p7S9W7QorENrUU65fqS/k8TsHyC9nNIqh4R+8JK/LMS3WLLDYzgweBZB0w8DOinY09b40TASeBTDpTChHTPMplEtjwYf+3pXENe0+l1IL5Fg6MFwyzwB3Fu0TleF7L6DOcfqUXosUaZLNU9qJxY8JagyNUXR+Ir5HLxi7jnf7iSTIqrl50i8v3DDf3AJFcWJ6lU6QaZSIplr4hH2oXPV9enqpmnOklQQL85gX/AeKkMzLYMLgVohjgFIVf7CVY9nACrJdwf9GmVp4T4fZWeI3Ri4bkrdng3xo9nprPstplAibXs6jnJafyenxOuy0w0b/4ZcEURJqlffr73PyXTvp6G3AWYuh8eVPuoH7ZsDn--4gECL9gWcOwxSmB8--XL8H1uFYRwrciKV+dHvH8w== -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem "sqlite3" 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: storage/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: storage/test.sqlite3 22 | 23 | 24 | # Store production database in the storage/ directory, which by default 25 | # is mounted as a persistent Docker volume in config/deploy.yml. 26 | production: 27 | primary: 28 | <<: *default 29 | database: storage/production.sqlite3 30 | cache: 31 | <<: *default 32 | database: storage/production_cache.sqlite3 33 | migrations_paths: db/cache_migrate 34 | queue: 35 | <<: *default 36 | database: storage/production_queue.sqlite3 37 | migrations_paths: db/queue_migrate 38 | cable: 39 | <<: *default 40 | database: storage/production_cable.sqlite3 41 | migrations_paths: db/cable_migrate 42 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Make code changes take effect immediately without server restart. 7 | config.enable_reloading = true 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable server timing. 16 | config.server_timing = true 17 | 18 | # Enable/disable Action Controller caching. By default Action Controller caching is disabled. 19 | # Run rails dev:cache to toggle Action Controller caching. 20 | if Rails.root.join("tmp/caching-dev.txt").exist? 21 | config.action_controller.perform_caching = true 22 | config.action_controller.enable_fragment_cache_logging = true 23 | config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } 24 | else 25 | config.action_controller.perform_caching = false 26 | end 27 | 28 | # Change to :null_store to avoid any caching. 29 | config.cache_store = :memory_store 30 | 31 | # Store uploaded files on the local file system (see config/storage.yml for options). 32 | config.active_storage.service = :local 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Raise an error on page load if there are pending migrations. 38 | config.active_record.migration_error = :page_load 39 | 40 | # Highlight code that triggered database queries in logs. 41 | config.active_record.verbose_query_logs = true 42 | 43 | # Append comments with runtime information tags to SQL queries in logs. 44 | config.active_record.query_log_tags_enabled = true 45 | 46 | # Annotate rendered view with file names. 47 | config.action_view.annotate_rendered_view_with_filenames = true 48 | 49 | # Uncomment if you wish to allow Action Cable access from any origin. 50 | # config.action_cable.disable_request_forgery_protection = true 51 | 52 | # Raise error when a before_action's only/except options reference missing actions. 53 | config.action_controller.raise_on_missing_callback_actions = true 54 | 55 | # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. 56 | # config.generators.apply_rubocop_autocorrect_after_generate! 57 | end 58 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.enable_reloading = false 8 | 9 | # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). 10 | config.eager_load = true 11 | 12 | # Full error reports are disabled. 13 | config.consider_all_requests_local = false 14 | 15 | # Turn on fragment caching in view templates. 16 | config.action_controller.perform_caching = true 17 | 18 | # Cache assets for far-future expiry since they are all digest stamped. 19 | config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } 20 | 21 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 22 | # config.asset_host = "http://assets.example.com" 23 | 24 | # Store uploaded files on the local file system (see config/storage.yml for options). 25 | config.active_storage.service = :local 26 | 27 | # Assume all access to the app is happening through a SSL-terminating reverse proxy. 28 | config.assume_ssl = true 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | config.force_ssl = true 32 | 33 | # Skip http-to-https redirect for the default health check endpoint. 34 | # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } 35 | 36 | # Log to STDOUT with the current request id as a default log tag. 37 | config.log_tags = [ :request_id ] 38 | config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) 39 | 40 | # Change to "debug" to log everything (including potentially personally-identifiable information!) 41 | config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") 42 | 43 | # Prevent health checks from clogging up the logs. 44 | config.silence_healthcheck_path = "/up" 45 | 46 | # Don't log any deprecations. 47 | config.active_support.report_deprecations = false 48 | 49 | # Replace the default in-process memory cache store with a durable alternative. 50 | config.cache_store = :solid_cache_store 51 | 52 | # Replace the default in-process and non-durable queuing backend for Active Job. 53 | config.active_job.queue_adapter = :solid_queue 54 | config.solid_queue.connects_to = { database: { writing: :queue } } 55 | 56 | # Ignore bad email addresses and do not raise email delivery errors. 57 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 58 | # config.action_mailer.raise_delivery_errors = false 59 | 60 | # Set host to be used by links generated in mailer templates. 61 | config.action_mailer.default_url_options = { host: "example.com" } 62 | 63 | # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. 64 | # config.action_mailer.smtp_settings = { 65 | # user_name: Rails.application.credentials.dig(:smtp, :user_name), 66 | # password: Rails.application.credentials.dig(:smtp, :password), 67 | # address: "smtp.example.com", 68 | # port: 587, 69 | # authentication: :plain 70 | # } 71 | 72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 73 | # the I18n.default_locale when a translation cannot be found). 74 | config.i18n.fallbacks = true 75 | 76 | # Do not dump schema after migrations. 77 | config.active_record.dump_schema_after_migration = false 78 | 79 | # Only use :id for inspections in production. 80 | config.active_record.attributes_for_inspect = [ :id ] 81 | 82 | # Enable DNS rebinding protection and other `Host` header attacks. 83 | # config.hosts = [ 84 | # "example.com", # Allow requests from example.com 85 | # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` 86 | # ] 87 | # 88 | # Skip DNS rebinding protection for the default health check endpoint. 89 | # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } 90 | end 91 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # The test environment is used exclusively to run your application's 2 | # test suite. You never need to work with it otherwise. Remember that 3 | # your test database is "scratch space" for the test suite and is wiped 4 | # and recreated between test runs. Don't rely on the data there! 5 | 6 | Rails.application.configure do 7 | # Settings specified here will take precedence over those in config/application.rb. 8 | 9 | # While tests run files are not watched, reloading is not necessary. 10 | config.enable_reloading = false 11 | 12 | # Eager loading loads your entire application. When running a single test locally, 13 | # this is usually not necessary, and can slow down your test suite. However, it's 14 | # recommended that you enable it in continuous integration systems to ensure eager 15 | # loading is working properly before deploying your code. 16 | config.eager_load = ENV["CI"].present? 17 | 18 | # Configure public file server for tests with cache-control for performance. 19 | config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } 20 | 21 | # Show full error reports. 22 | config.consider_all_requests_local = true 23 | config.cache_store = :null_store 24 | 25 | # Render exception templates for rescuable exceptions and raise for other exceptions. 26 | config.action_dispatch.show_exceptions = :rescuable 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory. 32 | config.active_storage.service = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations. 38 | # config.i18n.raise_on_missing_translations = true 39 | 40 | # Annotate rendered view with file names. 41 | # config.action_view.annotate_rendered_view_with_filenames = true 42 | 43 | # Raise error when a before_action's only/except options reference missing actions. 44 | config.action_controller.raise_on_missing_callback_actions = true 45 | end 46 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/importmap.rb: -------------------------------------------------------------------------------- 1 | # Pin npm packages by running ./bin/importmap 2 | 3 | pin "application" 4 | pin "@hotwired/turbo-rails", to: "turbo.min.js" 5 | pin "@hotwired/stimulus", to: "stimulus.min.js" 6 | pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" 7 | pin_all_from "app/javascript/controllers", under: "controllers" 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap, inline scripts, and inline styles. 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src style-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. 4 | # Use this to limit dissemination of sensitive information. 5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc 8 | ] 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization and 2 | # are automatically loaded by Rails. If you want to use locales other than 3 | # English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more about the API, please read the Rails Internationalization guide 20 | # at https://guides.rubyonrails.org/i18n.html. 21 | # 22 | # Be aware that YAML interprets the following case-insensitive strings as 23 | # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings 24 | # must be quoted to be interpreted as strings. For example: 25 | # 26 | # en: 27 | # "yes": yup 28 | # enabled: "ON" 29 | 30 | en: 31 | hello: "Hello world" 32 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/master.key: -------------------------------------------------------------------------------- 1 | 736ebc816482b7db1bc172090daf90b1 -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/puma.rb: -------------------------------------------------------------------------------- 1 | # This configuration file will be evaluated by Puma. The top-level methods that 2 | # are invoked here are part of Puma's configuration DSL. For more information 3 | # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. 4 | # 5 | # Puma starts a configurable number of processes (workers) and each process 6 | # serves each request in a thread from an internal thread pool. 7 | # 8 | # You can control the number of workers using ENV["WEB_CONCURRENCY"]. You 9 | # should only set this value when you want to run 2 or more workers. The 10 | # default is already 1. 11 | # 12 | # The ideal number of threads per worker depends both on how much time the 13 | # application spends waiting for IO operations and on how much you wish to 14 | # prioritize throughput over latency. 15 | # 16 | # As a rule of thumb, increasing the number of threads will increase how much 17 | # traffic a given process can handle (throughput), but due to CRuby's 18 | # Global VM Lock (GVL) it has diminishing returns and will degrade the 19 | # response time (latency) of the application. 20 | # 21 | # The default is set to 3 threads as it's deemed a decent compromise between 22 | # throughput and latency for the average Rails application. 23 | # 24 | # Any libraries that use a connection pool or another resource pool should 25 | # be configured to provide at least as many connections as the number of 26 | # threads. This includes Active Record's `pool` parameter in `database.yml`. 27 | threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) 28 | threads threads_count, threads_count 29 | 30 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 31 | port ENV.fetch("PORT", 3000) 32 | 33 | # Allow puma to be restarted by `bin/rails restart` command. 34 | plugin :tmp_restart 35 | 36 | # Run the Solid Queue supervisor inside of Puma for single-server deployments 37 | plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] 38 | 39 | # Specify the PID file. Defaults to tmp/pids/server.pid in development. 40 | # In other environments, only set the PID file if requested. 41 | pidfile ENV["PIDFILE"] if ENV["PIDFILE"] 42 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/queue.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | dispatchers: 3 | - polling_interval: 1 4 | batch_size: 500 5 | workers: 6 | - queues: "*" 7 | threads: 3 8 | processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> 9 | polling_interval: 0.1 10 | 11 | development: 12 | <<: *default 13 | 14 | test: 15 | <<: *default 16 | 17 | production: 18 | <<: *default 19 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/recurring.yml: -------------------------------------------------------------------------------- 1 | # production: 2 | # periodic_cleanup: 3 | # class: CleanSoftDeletedRecordsJob 4 | # queue: background 5 | # args: [ 1000, { batch_size: 500 } ] 6 | # schedule: every hour 7 | # periodic_command: 8 | # command: "SoftDeletedRecord.due.delete_all" 9 | # priority: 2 10 | # schedule: at 5am every day 11 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :posts 3 | root 'posts#index' 4 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 5 | end 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/db/cable_schema.rb: -------------------------------------------------------------------------------- 1 | ActiveRecord::Schema[7.1].define(version: 1) do 2 | create_table "solid_cable_messages", force: :cascade do |t| 3 | t.binary "channel", limit: 1024, null: false 4 | t.binary "payload", limit: 536870912, null: false 5 | t.datetime "created_at", null: false 6 | t.integer "channel_hash", limit: 8, null: false 7 | t.index ["channel"], name: "index_solid_cable_messages_on_channel" 8 | t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash" 9 | t.index ["created_at"], name: "index_solid_cable_messages_on_created_at" 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/db/cache_schema.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | ActiveRecord::Schema[7.2].define(version: 1) do 4 | create_table "solid_cache_entries", force: :cascade do |t| 5 | t.binary "key", limit: 1024, null: false 6 | t.binary "value", limit: 536870912, null: false 7 | t.datetime "created_at", null: false 8 | t.integer "key_hash", limit: 8, null: false 9 | t.integer "byte_size", limit: 4, null: false 10 | t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size" 11 | t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size" 12 | t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/db/migrate/20180621085832_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration[7.2] 2 | def change 3 | create_table :posts do |t| 4 | t.string :title 5 | t.text :body 6 | t.boolean :published 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should ensure the existence of records required to run the application in every environment (production, 2 | # development, test). The code here should be idempotent so that it can be executed at any point in every environment. 3 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 | # 5 | # Example: 6 | # 7 | # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| 8 | # MovieGenre.find_or_create_by!(name: genre_name) 9 | # end 10 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@playwright/test": "^1.50.1", 4 | "cypress": "^14.0.3", 5 | "cypress-on-rails": "^0.1.0", 6 | "playwright": "^1.50.1" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/public/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/public/icon.png -------------------------------------------------------------------------------- /specs_e2e/rails_8/public/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/storage/.keep -------------------------------------------------------------------------------- /specs_e2e/rails_8/storage/test.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/storage/test.sqlite3 -------------------------------------------------------------------------------- /specs_e2e/rails_8/storage/test.sqlite3-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/storage/test.sqlite3-shm -------------------------------------------------------------------------------- /specs_e2e/rails_8/storage/test.sqlite3-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/storage/test.sqlite3-wal -------------------------------------------------------------------------------- /specs_e2e/rails_8/test-results/.last-run.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "passed", 3 | "failedTests": [] 4 | } -------------------------------------------------------------------------------- /specs_e2e/rails_8/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | echo '--- testing rails 8' 5 | 6 | echo '-- setting environment' 7 | export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | export RAILS_ENV=test 9 | export BUNDLE_GEMFILE="$DIR/Gemfile" 10 | cd $DIR 11 | 12 | echo '-- bundle install' 13 | bundle --version 14 | bundle config set --local path 'vendor/bundle' 15 | bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 16 | 17 | echo '-- migration' 18 | bundle exec ./bin/rails db:drop || true 19 | bundle exec ./bin/rails db:create db:migrate 20 | 21 | echo '-- cypress install' 22 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework cypress --install_with=npm --force 23 | rm -vf test/cypress/e2e/rails_examples/using_vcr.cy.js 24 | 25 | echo '-- start rails server' 26 | # make sure the server is not running 27 | (kill -9 `cat ../server.pid` || true ) 28 | 29 | bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & 30 | sleep 2 # give rails a chance to start up correctly 31 | 32 | echo '-- cypress run' 33 | cp -fv ../cypress.config.js test/ 34 | cd test 35 | npx cypress install 36 | # if [ -z $CYPRESS_RECORD_KEY ] 37 | # then 38 | # npx cypress run 39 | # else 40 | npx cypress run # --record 41 | # fi 42 | 43 | echo '-- playwright install' 44 | cd .. 45 | bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework playwright --install_with=npm --force 46 | rm -vf test/playwright/e2e/rails_examples/using_vcr.cy.js 47 | 48 | echo '-- playwright run' 49 | cd test 50 | cp -fv ../../playwright.config.js . 51 | npx playwright install-deps 52 | npx playwright install 53 | npx playwright test test/playwright 54 | # npx playwright show-report 55 | 56 | echo '-- stop rails server' 57 | kill -9 `cat ../../server.pid` || true 58 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] 5 | end 6 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/controllers/posts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @post = posts(:one) 6 | end 7 | 8 | test "should get index" do 9 | get posts_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_post_url 15 | assert_response :success 16 | end 17 | 18 | test "should create post" do 19 | assert_difference('Post.count') do 20 | post posts_url, params: { post: { body: @post.body, published: @post.published, title: @post.title } } 21 | end 22 | 23 | assert_redirected_to post_url(Post.last) 24 | end 25 | 26 | test "should show post" do 27 | get post_url(@post) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_post_url(@post) 33 | assert_response :success 34 | end 35 | 36 | test "should update post" do 37 | patch post_url(@post), params: { post: { body: @post.body, published: @post.published, title: @post.title } } 38 | assert_redirected_to post_url(@post) 39 | end 40 | 41 | test "should destroy post" do 42 | assert_difference('Post.count', -1) do 43 | delete post_url(@post) 44 | end 45 | 46 | assert_redirected_to posts_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/cypress_fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyCypressFixtures 5 | body: MyText 6 | published: true 7 | 8 | two: 9 | title: MyCypressFixtures2 10 | body: MyText 11 | published: true 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyRailsFixtures 5 | body: MyText 6 | published: false 7 | 8 | two: 9 | title: MyRailsFixtures2 10 | body: MyText 11 | published: false 12 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/models/post_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PostTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require_relative "../config/environment" 3 | require "rails/test_help" 4 | 5 | module ActiveSupport 6 | class TestCase 7 | # Run tests in parallel with specified workers 8 | parallelize(workers: :number_of_processors) 9 | 10 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 11 | fixtures :all 12 | 13 | # Add more helper methods to be used by all tests here... 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /specs_e2e/rails_8/vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/vendor/.keep -------------------------------------------------------------------------------- /specs_e2e/rails_8/vendor/javascript/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/specs_e2e/rails_8/vendor/javascript/.keep -------------------------------------------------------------------------------- /tmp/pids/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shakacode/cypress-playwright-on-rails/c89651ea170378d5e07156add71dbb2efed89c38/tmp/pids/.gitkeep --------------------------------------------------------------------------------