From 641ebbbc936699ea3744290fdbdcbd53765172dd Mon Sep 17 00:00:00 2001 From: John Pitchko Date: Thu, 3 Oct 2024 21:09:03 -0600 Subject: [PATCH 1/5] Explain how to set a default driver for system specs --- features/system_specs/system_specs.feature | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index bb729ac3f..7cb11715b 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -19,7 +19,15 @@ Feature: System specs RSpec **does not** use your `ApplicationSystemTestCase` helper. Instead it uses the default `driven_by(:selenium)` from Rails. If you want to override - this behaviour you can call `driven_by` manually in a test. + this behaviour you can call `driven_by` manually in a test. Alternatively, + if you want to specify a default driver for all system specs (rather than + using `driven_by` in every spec), add the following to `spec/rails_helper.rb`: + + ``` + config.before(type: :system) do + driven_by :selenium_headless # Or your preferred default driver + end + ``` System specs run in a transaction. So unlike feature specs with javascript, you do not need [DatabaseCleaner](https://github.com/DatabaseCleaner/database_cleaner). From 8fdbe4ebef698a4716fcda697305da8127e605a6 Mon Sep 17 00:00:00 2001 From: John Pitchko Date: Fri, 4 Oct 2024 08:41:35 -0600 Subject: [PATCH 2/5] Update features/system_specs/system_specs.feature Co-authored-by: Jon Rowe --- features/system_specs/system_specs.feature | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index 7cb11715b..ed9d29b1c 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -19,9 +19,11 @@ Feature: System specs RSpec **does not** use your `ApplicationSystemTestCase` helper. Instead it uses the default `driven_by(:selenium)` from Rails. If you want to override - this behaviour you can call `driven_by` manually in a test. Alternatively, - if you want to specify a default driver for all system specs (rather than - using `driven_by` in every spec), add the following to `spec/rails_helper.rb`: + this behaviour you need to call `driven_by` in your specs. + + This can either be done manually in the spec files themselves or + you can use the configuration helpers to do this for every system spec, + for example by adding the following to `spec/rails_helper.rb`: ``` config.before(type: :system) do From 903db86e72740ac8c7be08a4a278ad280a272e96 Mon Sep 17 00:00:00 2001 From: John Pitchko Date: Fri, 4 Oct 2024 08:41:40 -0600 Subject: [PATCH 3/5] Update features/system_specs/system_specs.feature Co-authored-by: Jon Rowe --- features/system_specs/system_specs.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index ed9d29b1c..59103618b 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -27,7 +27,7 @@ Feature: System specs ``` config.before(type: :system) do - driven_by :selenium_headless # Or your preferred default driver + driven_by :selenium_headless # Or your preferred default driver end ``` From 37fe835c548acc047b9e555e9c9cc851215eae12 Mon Sep 17 00:00:00 2001 From: John Pitchko Date: Fri, 4 Oct 2024 08:43:46 -0600 Subject: [PATCH 4/5] Provide more context in example --- features/system_specs/system_specs.feature | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index 59103618b..650508885 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -26,8 +26,12 @@ Feature: System specs for example by adding the following to `spec/rails_helper.rb`: ``` - config.before(type: :system) do - driven_by :selenium_headless # Or your preferred default driver + RSpec.configure do |config| + ... + config.before(type: :system) do + driven_by :selenium_headless # Or your preferred default driver + end + ... end ``` From f915410c3b174b8319749d006e01677815722890 Mon Sep 17 00:00:00 2001 From: John Pitchko Date: Fri, 4 Oct 2024 08:50:39 -0600 Subject: [PATCH 5/5] Update features/system_specs/system_specs.feature Co-authored-by: Nate Matykiewicz --- features/system_specs/system_specs.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index 650508885..33b893010 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -25,7 +25,7 @@ Feature: System specs you can use the configuration helpers to do this for every system spec, for example by adding the following to `spec/rails_helper.rb`: - ``` + ```ruby RSpec.configure do |config| ... config.before(type: :system) do