cypress-on-rails 1.18.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/claude-code-review.yml +57 -0
  3. data/.github/workflows/claude.yml +50 -0
  4. data/CHANGELOG.md +399 -98
  5. data/README.md +139 -19
  6. data/RELEASING.md +200 -0
  7. data/Rakefile +1 -4
  8. data/cypress-on-rails.gemspec +3 -2
  9. data/docs/BEST_PRACTICES.md +678 -0
  10. data/docs/DX_IMPROVEMENTS.md +163 -0
  11. data/docs/PLAYWRIGHT_GUIDE.md +554 -0
  12. data/docs/RELEASE.md +124 -0
  13. data/docs/TROUBLESHOOTING.md +351 -0
  14. data/docs/VCR_GUIDE.md +499 -0
  15. data/lib/cypress_on_rails/command_executor.rb +24 -0
  16. data/lib/cypress_on_rails/configuration.rb +32 -0
  17. data/lib/cypress_on_rails/railtie.rb +7 -0
  18. data/lib/cypress_on_rails/server.rb +258 -0
  19. data/lib/cypress_on_rails/state_reset_middleware.rb +58 -0
  20. data/lib/cypress_on_rails/version.rb +1 -1
  21. data/lib/generators/cypress_on_rails/install_generator.rb +2 -2
  22. data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +14 -2
  23. data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_factory_bot.cy.js +2 -2
  24. data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_scenarios.cy.js +1 -1
  25. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +1 -1
  26. data/lib/tasks/cypress.rake +33 -0
  27. data/rakelib/release.rake +80 -0
  28. data/rakelib/task_helpers.rb +23 -0
  29. data/rakelib/update_changelog.rake +63 -0
  30. data/spec/cypress_on_rails/configuration_spec.rb +6 -0
  31. data/spec/generators/install_generator_spec.rb +222 -0
  32. metadata +34 -4
@@ -0,0 +1,222 @@
1
+ require 'spec_helper'
2
+ require 'rails/generators'
3
+ require 'generators/cypress_on_rails/install_generator'
4
+ require 'tmpdir'
5
+ require 'fileutils'
6
+
7
+ RSpec.describe CypressOnRails::InstallGenerator, type: :generator do
8
+ let(:destination_root) { Dir.mktmpdir }
9
+
10
+ before do
11
+ # Set up a minimal Rails app structure
12
+ FileUtils.mkdir_p(File.join(destination_root, 'config', 'initializers'))
13
+ FileUtils.mkdir_p(File.join(destination_root, 'bin'))
14
+
15
+ # Mock the generator's destination_root
16
+ allow(Dir).to receive(:pwd).and_return(destination_root)
17
+
18
+ # Prevent actual npm/yarn installation in tests
19
+ # Mock only package manager commands, let file operations through
20
+ allow_any_instance_of(CypressOnRails::InstallGenerator).to receive(:system) do |_, command|
21
+ # Return true for yarn/npm install commands to skip actual installation
22
+ command.to_s.match?(/yarn|npm/)
23
+ end
24
+ end
25
+
26
+ after do
27
+ FileUtils.rm_rf(destination_root)
28
+ end
29
+
30
+ describe 'with default options (cypress framework, e2e folder)' do
31
+ let(:args) { [] }
32
+ let(:options) { {} }
33
+
34
+ before do
35
+ run_generator(args, options)
36
+ end
37
+
38
+ it 'creates the initializer with correct install_folder path' do
39
+ initializer_path = File.join(destination_root, 'config', 'initializers', 'cypress_on_rails.rb')
40
+ expect(File).to exist(initializer_path)
41
+
42
+ content = File.read(initializer_path)
43
+ # Should point to e2e, not e2e/cypress
44
+ expect(content).to include('c.install_folder = File.expand_path("#{__dir__}/../../e2e")')
45
+ end
46
+
47
+ it 'creates cypress config at install_folder root' do
48
+ config_path = File.join(destination_root, 'e2e', 'cypress.config.js')
49
+ expect(File).to exist(config_path)
50
+ end
51
+
52
+ it 'creates e2e_helper.rb at install_folder root' do
53
+ helper_path = File.join(destination_root, 'e2e', 'e2e_helper.rb')
54
+ expect(File).to exist(helper_path)
55
+ end
56
+
57
+ it 'creates app_commands directory at install_folder root' do
58
+ commands_path = File.join(destination_root, 'e2e', 'app_commands')
59
+ expect(File).to be_directory(commands_path)
60
+ end
61
+
62
+ it 'creates cypress support files in framework subdirectory' do
63
+ support_path = File.join(destination_root, 'e2e', 'cypress', 'support', 'index.js')
64
+ expect(File).to exist(support_path)
65
+ end
66
+
67
+ it 'creates cypress examples in framework subdirectory' do
68
+ examples_path = File.join(destination_root, 'e2e', 'cypress', 'e2e', 'rails_examples')
69
+ expect(File).to be_directory(examples_path)
70
+ end
71
+ end
72
+
73
+ describe 'with playwright framework' do
74
+ let(:args) { [] }
75
+ let(:options) { { framework: 'playwright' } }
76
+
77
+ before do
78
+ run_generator(args, options)
79
+ end
80
+
81
+ it 'creates the initializer with correct install_folder path' do
82
+ initializer_path = File.join(destination_root, 'config', 'initializers', 'cypress_on_rails.rb')
83
+ expect(File).to exist(initializer_path)
84
+
85
+ content = File.read(initializer_path)
86
+ # Should point to e2e, not e2e/playwright
87
+ expect(content).to include('c.install_folder = File.expand_path("#{__dir__}/../../e2e")')
88
+ end
89
+
90
+ it 'creates playwright config at install_folder root' do
91
+ config_path = File.join(destination_root, 'e2e', 'playwright.config.js')
92
+ expect(File).to exist(config_path)
93
+ end
94
+
95
+ it 'creates e2e_helper.rb at install_folder root' do
96
+ helper_path = File.join(destination_root, 'e2e', 'e2e_helper.rb')
97
+ expect(File).to exist(helper_path)
98
+ end
99
+
100
+ it 'creates app_commands directory at install_folder root' do
101
+ commands_path = File.join(destination_root, 'e2e', 'app_commands')
102
+ expect(File).to be_directory(commands_path)
103
+ end
104
+
105
+ it 'creates playwright support files in framework subdirectory' do
106
+ support_path = File.join(destination_root, 'e2e', 'playwright', 'support', 'index.js')
107
+ expect(File).to exist(support_path)
108
+ end
109
+
110
+ it 'creates playwright examples in framework subdirectory' do
111
+ examples_path = File.join(destination_root, 'e2e', 'playwright', 'e2e', 'rails_examples')
112
+ expect(File).to be_directory(examples_path)
113
+ end
114
+ end
115
+
116
+ describe 'with custom install_folder' do
117
+ let(:args) { [] }
118
+ let(:options) { { install_folder: 'spec/system' } }
119
+
120
+ before do
121
+ run_generator(args, options)
122
+ end
123
+
124
+ it 'creates files in the custom folder' do
125
+ helper_path = File.join(destination_root, 'spec', 'system', 'e2e_helper.rb')
126
+ expect(File).to exist(helper_path)
127
+
128
+ commands_path = File.join(destination_root, 'spec', 'system', 'app_commands')
129
+ expect(File).to be_directory(commands_path)
130
+ end
131
+
132
+ it 'sets the correct install_folder in the initializer' do
133
+ initializer_path = File.join(destination_root, 'config', 'initializers', 'cypress_on_rails.rb')
134
+ content = File.read(initializer_path)
135
+ expect(content).to include('c.install_folder = File.expand_path("#{__dir__}/../../spec/system")')
136
+ end
137
+ end
138
+
139
+ describe 'file structure ensures middleware and framework compatibility' do
140
+ let(:args) { [] }
141
+ let(:options) { {} }
142
+
143
+ before do
144
+ run_generator(args, options)
145
+ end
146
+
147
+ it 'does not create e2e_helper.rb in old location (framework subdirectory)' do
148
+ old_cypress_path = File.join(destination_root, 'e2e', 'cypress', 'e2e_helper.rb')
149
+ old_playwright_path = File.join(destination_root, 'e2e', 'playwright', 'e2e_helper.rb')
150
+ expect(File).not_to exist(old_cypress_path)
151
+ expect(File).not_to exist(old_playwright_path)
152
+ end
153
+
154
+ it 'does not create app_commands in old location (framework subdirectory)' do
155
+ old_cypress_path = File.join(destination_root, 'e2e', 'cypress', 'app_commands')
156
+ old_playwright_path = File.join(destination_root, 'e2e', 'playwright', 'app_commands')
157
+ expect(File).not_to exist(old_cypress_path)
158
+ expect(File).not_to exist(old_playwright_path)
159
+ end
160
+
161
+ it 'places e2e_helper.rb where middleware expects it (install_folder/e2e_helper.rb)' do
162
+ # Middleware looks for #{install_folder}/e2e_helper.rb
163
+ helper_path = File.join(destination_root, 'e2e', 'e2e_helper.rb')
164
+ expect(File).to exist(helper_path)
165
+ expect(File.read(helper_path)).to include('CypressOnRails')
166
+ end
167
+
168
+ it 'places app_commands where middleware expects it (install_folder/app_commands)' do
169
+ # Middleware looks for #{install_folder}/app_commands/#{command}.rb
170
+ commands_path = File.join(destination_root, 'e2e', 'app_commands')
171
+ expect(File).to be_directory(commands_path)
172
+
173
+ # Check that command files exist
174
+ clean_cmd = File.join(commands_path, 'clean.rb')
175
+ expect(File).to exist(clean_cmd)
176
+ end
177
+
178
+ it 'places cypress.config.js where cypress --project flag expects it' do
179
+ # Cypress runs with --project install_folder, expects config at that level
180
+ config_path = File.join(destination_root, 'e2e', 'cypress.config.js')
181
+ expect(File).to exist(config_path)
182
+
183
+ # Verify the config references the correct relative path for support files
184
+ content = File.read(config_path)
185
+ expect(content).to include('cypress/support/index.js')
186
+ end
187
+
188
+ it 'creates a valid directory structure' do
189
+ # The expected structure:
190
+ # e2e/
191
+ # cypress.config.js <- Config at root of install_folder
192
+ # e2e_helper.rb <- Helper at root of install_folder
193
+ # app_commands/ <- Commands at root of install_folder
194
+ # cypress/ <- Framework-specific subdirectory
195
+ # support/
196
+ # e2e/
197
+
198
+ expect(File).to exist(File.join(destination_root, 'e2e', 'cypress.config.js'))
199
+ expect(File).to exist(File.join(destination_root, 'e2e', 'e2e_helper.rb'))
200
+ expect(File).to be_directory(File.join(destination_root, 'e2e', 'app_commands'))
201
+ expect(File).to be_directory(File.join(destination_root, 'e2e', 'cypress'))
202
+ expect(File).to be_directory(File.join(destination_root, 'e2e', 'cypress', 'support'))
203
+ expect(File).to be_directory(File.join(destination_root, 'e2e', 'cypress', 'e2e'))
204
+ end
205
+ end
206
+
207
+ def run_generator(args, options)
208
+ generator_options = []
209
+ options.each do |key, value|
210
+ generator_options << "--#{key}=#{value}"
211
+ end
212
+
213
+ CypressOnRails::InstallGenerator.start(
214
+ args + generator_options,
215
+ {
216
+ destination_root: destination_root,
217
+ shell: Thor::Shell::Basic.new,
218
+ behavior: :invoke
219
+ }
220
+ )
221
+ end
222
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cypress-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miceportal team
@@ -94,7 +94,21 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Integrates cypress with rails or rack applications
97
+ - !ruby/object:Gem::Dependency
98
+ name: gem-release
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Integrates Cypress and Playwright with Rails or Rack applications
98
112
  email:
99
113
  - info@miceportal.de
100
114
  - grantspeelman@gmail.com
@@ -103,6 +117,8 @@ extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
105
119
  - ".github/FUNDING.yml"
120
+ - ".github/workflows/claude-code-review.yml"
121
+ - ".github/workflows/claude.yml"
106
122
  - ".github/workflows/ruby.yml"
107
123
  - ".gitignore"
108
124
  - ".rspec"
@@ -110,8 +126,15 @@ files:
110
126
  - Gemfile
111
127
  - LICENSE
112
128
  - README.md
129
+ - RELEASING.md
113
130
  - Rakefile
114
131
  - cypress-on-rails.gemspec
132
+ - docs/BEST_PRACTICES.md
133
+ - docs/DX_IMPROVEMENTS.md
134
+ - docs/PLAYWRIGHT_GUIDE.md
135
+ - docs/RELEASE.md
136
+ - docs/TROUBLESHOOTING.md
137
+ - docs/VCR_GUIDE.md
115
138
  - docs/authentication.md
116
139
  - docs/factory_bot_associations.md
117
140
  - lib/cypress-on-rails.rb
@@ -124,8 +147,10 @@ files:
124
147
  - lib/cypress_on_rails/middleware.rb
125
148
  - lib/cypress_on_rails/middleware_config.rb
126
149
  - lib/cypress_on_rails/railtie.rb
150
+ - lib/cypress_on_rails/server.rb
127
151
  - lib/cypress_on_rails/simple_rails_factory.rb
128
152
  - lib/cypress_on_rails/smart_factory_wrapper.rb
153
+ - lib/cypress_on_rails/state_reset_middleware.rb
129
154
  - lib/cypress_on_rails/vcr/insert_eject_middleware.rb
130
155
  - lib/cypress_on_rails/vcr/middleware_helpers.rb
131
156
  - lib/cypress_on_rails/vcr/use_cassette_middleware.rb
@@ -153,10 +178,14 @@ files:
153
178
  - lib/generators/cypress_on_rails/templates/spec/playwright/e2e/rails_examples/using_scenarios.spec.js
154
179
  - lib/generators/cypress_on_rails/templates/spec/playwright/support/index.js.erb
155
180
  - lib/generators/cypress_on_rails/templates/spec/playwright/support/on-rails.js
181
+ - lib/tasks/cypress.rake
156
182
  - plugin/.gitignore
157
183
  - plugin/cypress/plugins/index.js
158
184
  - plugin/package.json
159
185
  - plugin/support/index.js
186
+ - rakelib/release.rake
187
+ - rakelib/task_helpers.rb
188
+ - rakelib/update_changelog.rake
160
189
  - spec/cypress_on_rails/command_executor/e2e_helper.rb
161
190
  - spec/cypress_on_rails/command_executor/test_command.rb
162
191
  - spec/cypress_on_rails/command_executor/test_command_with_options.rb
@@ -168,6 +197,7 @@ files:
168
197
  - spec/cypress_on_rails/smart_factory_wrapper_spec.rb
169
198
  - spec/cypress_on_rails/vcr/insert_eject_middleware_spec.rb
170
199
  - spec/cypress_on_rails/vcr/use_cassette_middleware_spec.rb
200
+ - spec/generators/install_generator_spec.rb
171
201
  - spec/spec_helper.rb
172
202
  - specs_e2e/cypress.config.js
173
203
  - specs_e2e/playwright.config.js
@@ -405,7 +435,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
435
  - !ruby/object:Gem::Version
406
436
  version: '0'
407
437
  requirements: []
408
- rubygems_version: 3.6.9
438
+ rubygems_version: 3.6.7
409
439
  specification_version: 4
410
- summary: Integrates cypress with rails or rack applications
440
+ summary: Integrates Cypress and Playwright with Rails or Rack applications
411
441
  test_files: []