From 5956f5f87ec6aa802c438777f7281238f70a4591 Mon Sep 17 00:00:00 2001 From: me3eh Date: Fri, 21 Feb 2025 13:09:01 +0100 Subject: [PATCH 1/3] Change rails server with test environment --- README.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0e9f10c..a58fff5 100644 --- a/README.md +++ b/README.md @@ -117,24 +117,6 @@ If you are not using `factory_bot` look at `e2e/cypress/app_commands/factory_bot Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit. -### Update your database.yml - -When writing and running tests on your local computer, it's recommended to start your server in development mode so that changes you -make are picked up without having to restart your local server. - -It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database -otherwise, cypress will keep clearing your development database. - -For example: -```yaml -development: - <<: *default - database: <%= ENV['CYPRESS'] ? 'my_db_test' : 'my_db_development' %> -test: - <<: *default - database: my_db_test -``` - ### WARNING *WARNING!!:* cypress-on-rails can execute arbitrary ruby code Please use with extra caution if starting your local server on 0.0.0.0 or running the gem on a hosted server @@ -144,8 +126,8 @@ Please use with extra caution if starting your local server on 0.0.0.0 or runnin Getting started on your local environment ```shell -# start rails -CYPRESS=1 bin/rails server -p 5017 +# start rails with test environment +CYPRESS=1 RAILS_ENV=test bin/rails server -p 5017 # in separate window start cypress yarn cypress open --project ./e2e From efdac131c6bbb4d3c374580b52fe051ff3b130de Mon Sep 17 00:00:00 2001 From: me3eh Date: Sun, 23 Feb 2025 22:27:12 +0100 Subject: [PATCH 2/3] Add enable_reloading to test.rb --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a58fff5..a8f391a 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,14 @@ If you are not using `factory_bot` look at `e2e/cypress/app_commands/factory_bot Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit. +## If you want to use live reload from rails + +Change the below setting in test.rb + +```ruby +config.enable_reloading = ENV['CYPRESS'].present? +``` + ### WARNING *WARNING!!:* cypress-on-rails can execute arbitrary ruby code Please use with extra caution if starting your local server on 0.0.0.0 or running the gem on a hosted server From 1026c5eaa03bc8e80286473e39e3b52bb51d0296 Mon Sep 17 00:00:00 2001 From: Maciej Boc <56845538+me3eh@users.noreply.github.com> Date: Wed, 13 Aug 2025 12:06:36 +0200 Subject: [PATCH 3/3] Little changes to description configuration --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a8f391a..b15c4db 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ Change the below setting in test.rb ```ruby config.enable_reloading = ENV['CYPRESS'].present? +... +config.action_controller.allow_forgery_protection = ENV["CYPRESS"].present? ``` ### WARNING @@ -133,6 +135,7 @@ Please use with extra caution if starting your local server on 0.0.0.0 or runnin Getting started on your local environment +Also anywhere in configuartion, if port `3000` exists, simply add ENV['CYPRESS'].present? ? `5017` : `3000` ```shell # start rails with test environment CYPRESS=1 RAILS_ENV=test bin/rails server -p 5017