cypress-on-rails 1.18.0 → 1.19.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.
- checksums.yaml +4 -4
- data/.github/workflows/claude-code-review.yml +57 -0
- data/.github/workflows/claude.yml +50 -0
- data/CHANGELOG.md +319 -98
- data/README.md +93 -1
- data/RELEASING.md +200 -0
- data/Rakefile +1 -4
- data/cypress-on-rails.gemspec +1 -0
- data/docs/BEST_PRACTICES.md +678 -0
- data/docs/DX_IMPROVEMENTS.md +163 -0
- data/docs/PLAYWRIGHT_GUIDE.md +554 -0
- data/docs/RELEASE.md +124 -0
- data/docs/TROUBLESHOOTING.md +351 -0
- data/docs/VCR_GUIDE.md +499 -0
- data/lib/cypress_on_rails/configuration.rb +24 -0
- data/lib/cypress_on_rails/railtie.rb +7 -0
- data/lib/cypress_on_rails/server.rb +197 -0
- data/lib/cypress_on_rails/state_reset_middleware.rb +58 -0
- data/lib/cypress_on_rails/version.rb +1 -1
- data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +12 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_factory_bot.cy.js +2 -2
- data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_scenarios.cy.js +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +1 -1
- data/lib/tasks/cypress.rake +33 -0
- data/rakelib/release.rake +80 -0
- data/rakelib/task_helpers.rb +23 -0
- data/rakelib/update_changelog.rake +63 -0
- metadata +31 -2
data/README.md
CHANGED
@@ -47,6 +47,28 @@ Consider first learning the basics of Playwright before attempting to integrate
|
|
47
47
|
|
48
48
|
* [Good start Here](https://playwright.dev/docs/writing-tests)
|
49
49
|
|
50
|
+
## Quick Start
|
51
|
+
|
52
|
+
```bash
|
53
|
+
# 1. Add to Gemfile
|
54
|
+
gem 'cypress-on-rails', '~> 1.0'
|
55
|
+
|
56
|
+
# 2. Install and generate
|
57
|
+
bundle install
|
58
|
+
bin/rails g cypress_on_rails:install
|
59
|
+
|
60
|
+
# 3. Run tests (new rake tasks!)
|
61
|
+
bin/rails cypress:open # Open Cypress UI
|
62
|
+
bin/rails cypress:run # Run headless
|
63
|
+
```
|
64
|
+
|
65
|
+
For Playwright:
|
66
|
+
```bash
|
67
|
+
bin/rails g cypress_on_rails:install --framework playwright
|
68
|
+
bin/rails playwright:open # Open Playwright UI
|
69
|
+
bin/rails playwright:run # Run headless
|
70
|
+
```
|
71
|
+
|
50
72
|
## Overview
|
51
73
|
|
52
74
|
Gem for using [cypress.io](http://github.com/cypress-io/) or [playwright.dev](https://playwright.dev/) in Rails and Ruby Rack applications to control state as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State).
|
@@ -64,7 +86,16 @@ Has examples of setting up state with:
|
|
64
86
|
* scenarios
|
65
87
|
* custom commands
|
66
88
|
|
67
|
-
##
|
89
|
+
## Documentation
|
90
|
+
|
91
|
+
### 📚 Essential Guides
|
92
|
+
* **[Best Practices Guide](docs/BEST_PRACTICES.md)** - Recommended patterns and practices
|
93
|
+
* **[Troubleshooting Guide](docs/TROUBLESHOOTING.md)** - Solutions to common issues
|
94
|
+
* **[Playwright Guide](docs/PLAYWRIGHT_GUIDE.md)** - Complete Playwright documentation
|
95
|
+
* **[VCR Integration Guide](docs/VCR_GUIDE.md)** - HTTP recording and mocking
|
96
|
+
* **[DX Improvements](docs/DX_IMPROVEMENTS.md)** - Recent improvements based on user feedback
|
97
|
+
|
98
|
+
### 🎥 Resources
|
68
99
|
* [Video of getting started with this gem](https://grant-ps.blog/2018/08/10/getting-started-with-cypress-io-and-ruby-on-rails/)
|
69
100
|
* [Article: Introduction to Cypress on Rails](https://www.shakacode.com/blog/introduction-to-cypress-on-rails/)
|
70
101
|
|
@@ -143,6 +174,29 @@ Please use with extra caution if starting your local server on 0.0.0.0 or runnin
|
|
143
174
|
|
144
175
|
Getting started on your local environment
|
145
176
|
|
177
|
+
### Using Rake Tasks (Recommended)
|
178
|
+
|
179
|
+
The easiest way to run tests is using the provided rake tasks, which automatically manage the Rails server:
|
180
|
+
|
181
|
+
```shell
|
182
|
+
# For Cypress
|
183
|
+
bin/rails cypress:open # Opens Cypress test runner UI
|
184
|
+
bin/rails cypress:run # Runs Cypress tests in headless mode
|
185
|
+
|
186
|
+
# For Playwright
|
187
|
+
bin/rails playwright:open # Opens Playwright test runner UI
|
188
|
+
bin/rails playwright:run # Runs Playwright tests in headless mode
|
189
|
+
```
|
190
|
+
|
191
|
+
These tasks will:
|
192
|
+
- Start the Rails test server automatically
|
193
|
+
- Execute your tests
|
194
|
+
- Stop the server when done
|
195
|
+
|
196
|
+
### Manual Server Management
|
197
|
+
|
198
|
+
You can also manage the server manually:
|
199
|
+
|
146
200
|
```shell
|
147
201
|
# start rails
|
148
202
|
CYPRESS=1 bin/rails server -p 5017
|
@@ -506,6 +560,44 @@ Consider VCR configuration in `cypress_helper.rb` to ignore hosts.
|
|
506
560
|
All cassettes will be recorded and saved automatically, using the pattern `<vcs_cassettes_path>/graphql/<operation_name>`
|
507
561
|
|
508
562
|
|
563
|
+
## Server Hooks Configuration
|
564
|
+
|
565
|
+
When using the rake tasks (`cypress:open`, `cypress:run`, `playwright:open`, `playwright:run`), you can configure lifecycle hooks to customize test server behavior:
|
566
|
+
|
567
|
+
```ruby
|
568
|
+
CypressOnRails.configure do |c|
|
569
|
+
# Run code before Rails server starts
|
570
|
+
c.before_server_start = -> {
|
571
|
+
puts "Preparing test environment..."
|
572
|
+
}
|
573
|
+
|
574
|
+
# Run code after Rails server is ready
|
575
|
+
c.after_server_start = -> {
|
576
|
+
puts "Server is ready for testing!"
|
577
|
+
}
|
578
|
+
|
579
|
+
# Run code after database transaction begins (transactional mode only)
|
580
|
+
c.after_transaction_start = -> {
|
581
|
+
# Load seed data that should be rolled back after tests
|
582
|
+
}
|
583
|
+
|
584
|
+
# Run code after application state is reset
|
585
|
+
c.after_state_reset = -> {
|
586
|
+
Rails.cache.clear
|
587
|
+
}
|
588
|
+
|
589
|
+
# Run code before Rails server stops
|
590
|
+
c.before_server_stop = -> {
|
591
|
+
puts "Cleaning up test environment..."
|
592
|
+
}
|
593
|
+
|
594
|
+
# Configure server settings
|
595
|
+
c.server_host = 'localhost' # or use ENV['CYPRESS_RAILS_HOST']
|
596
|
+
c.server_port = 3001 # or use ENV['CYPRESS_RAILS_PORT']
|
597
|
+
c.transactional_server = true # Enable automatic transaction rollback
|
598
|
+
end
|
599
|
+
```
|
600
|
+
|
509
601
|
## `before_request` configuration
|
510
602
|
|
511
603
|
You may perform any custom action before running a CypressOnRails command, such as authentication, or sending metrics. Please set `before_request` as part of the CypressOnRails configuration.
|
data/RELEASING.md
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
# Release Process
|
2
|
+
|
3
|
+
This document describes how to release a new version of cypress-playwright-on-rails.
|
4
|
+
|
5
|
+
## Prerequisites
|
6
|
+
|
7
|
+
1. Maintainer access to the repository
|
8
|
+
2. RubyGems account with publish permissions for `cypress-on-rails`
|
9
|
+
3. Clean working directory on `master` branch
|
10
|
+
4. Development dependencies installed: `bundle install`
|
11
|
+
- Includes `gem-release` for gem management (like react_on_rails)
|
12
|
+
|
13
|
+
## Release Command
|
14
|
+
|
15
|
+
The project uses a single rake task to automate the entire release process:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
rake release[VERSION,DRY_RUN]
|
19
|
+
```
|
20
|
+
|
21
|
+
### Examples
|
22
|
+
|
23
|
+
```bash
|
24
|
+
# Release version 1.19.0
|
25
|
+
rake release[1.19.0]
|
26
|
+
|
27
|
+
# Automatic patch version bump (e.g., 1.18.0 -> 1.18.1)
|
28
|
+
rake release
|
29
|
+
|
30
|
+
# Dry run to preview what would happen
|
31
|
+
rake release[1.19.0,true]
|
32
|
+
```
|
33
|
+
|
34
|
+
### What the Release Task Does
|
35
|
+
|
36
|
+
The `rake release` task will:
|
37
|
+
|
38
|
+
1. Pull latest changes from master
|
39
|
+
2. Bump the version in `lib/cypress_on_rails/version.rb`
|
40
|
+
3. Update `Gemfile.lock` via `bundle install`
|
41
|
+
4. Commit the version bump and Gemfile.lock changes
|
42
|
+
5. Create a git tag (e.g., `v1.19.0`)
|
43
|
+
6. Push the commit and tag to GitHub
|
44
|
+
7. Build and publish the gem to RubyGems (will prompt for OTP)
|
45
|
+
|
46
|
+
### Post-Release Steps
|
47
|
+
|
48
|
+
After publishing, complete these manual steps:
|
49
|
+
|
50
|
+
1. **Update CHANGELOG.md**
|
51
|
+
```bash
|
52
|
+
bundle exec rake update_changelog
|
53
|
+
git commit -a -m 'Update CHANGELOG.md'
|
54
|
+
git push
|
55
|
+
```
|
56
|
+
|
57
|
+
2. **Create GitHub Release**
|
58
|
+
- Go to the releases page: https://github.com/shakacode/cypress-playwright-on-rails/releases
|
59
|
+
- Click on the newly created tag
|
60
|
+
- Copy release notes from CHANGELOG.md
|
61
|
+
- Publish the release
|
62
|
+
|
63
|
+
3. **Announce the Release** (optional)
|
64
|
+
- Post in Slack channel
|
65
|
+
- Tweet about the release
|
66
|
+
- Update forum posts if needed
|
67
|
+
|
68
|
+
## Version Numbering
|
69
|
+
|
70
|
+
Follow [Semantic Versioning](https://semver.org/):
|
71
|
+
|
72
|
+
- **MAJOR** (X.0.0): Breaking changes
|
73
|
+
- **MINOR** (1.X.0): New features, backwards compatible
|
74
|
+
- **PATCH** (1.19.X): Bug fixes, backwards compatible
|
75
|
+
|
76
|
+
### Examples
|
77
|
+
|
78
|
+
```bash
|
79
|
+
# Patch release (bug fixes)
|
80
|
+
rake release[1.18.1]
|
81
|
+
|
82
|
+
# Minor release (new features)
|
83
|
+
rake release[1.19.0]
|
84
|
+
|
85
|
+
# Major release (breaking changes)
|
86
|
+
rake release[2.0.0]
|
87
|
+
|
88
|
+
# Automatic patch bump
|
89
|
+
rake release
|
90
|
+
```
|
91
|
+
|
92
|
+
## Pre-Release Checklist
|
93
|
+
|
94
|
+
Before running `rake release`:
|
95
|
+
|
96
|
+
- [ ] All PRs for the release are merged
|
97
|
+
- [ ] CI is passing on master
|
98
|
+
- [ ] CHANGELOG.md has [Unreleased] section with all changes
|
99
|
+
- [ ] Major changes have been tested manually
|
100
|
+
- [ ] Documentation is up to date
|
101
|
+
|
102
|
+
## Troubleshooting
|
103
|
+
|
104
|
+
### "Must be on master branch" error
|
105
|
+
|
106
|
+
```bash
|
107
|
+
git checkout master
|
108
|
+
git pull --rebase
|
109
|
+
```
|
110
|
+
|
111
|
+
### "Working directory is not clean" error
|
112
|
+
|
113
|
+
```bash
|
114
|
+
# Commit or stash your changes
|
115
|
+
git status
|
116
|
+
git add -A && git commit -m "Your message"
|
117
|
+
# or
|
118
|
+
git stash
|
119
|
+
```
|
120
|
+
|
121
|
+
|
122
|
+
### "Failed to push gem to RubyGems" error
|
123
|
+
|
124
|
+
Ensure you're authenticated with RubyGems:
|
125
|
+
```bash
|
126
|
+
gem signin
|
127
|
+
# Enter your RubyGems credentials
|
128
|
+
```
|
129
|
+
|
130
|
+
### Tag already exists
|
131
|
+
|
132
|
+
If you need to re-release the same version:
|
133
|
+
```bash
|
134
|
+
# Delete local tag
|
135
|
+
git tag -d v1.19.0
|
136
|
+
|
137
|
+
# Delete remote tag
|
138
|
+
git push origin :v1.19.0
|
139
|
+
|
140
|
+
# Reset to before the release commit
|
141
|
+
git reset --hard HEAD~1
|
142
|
+
|
143
|
+
# Try the release again
|
144
|
+
rake release[1.19.0]
|
145
|
+
```
|
146
|
+
|
147
|
+
## Rollback
|
148
|
+
|
149
|
+
If you need to rollback a release:
|
150
|
+
|
151
|
+
### Yank the gem from RubyGems
|
152
|
+
```bash
|
153
|
+
gem yank cypress-on-rails -v 1.19.0
|
154
|
+
```
|
155
|
+
|
156
|
+
### Delete the git tag
|
157
|
+
```bash
|
158
|
+
git tag -d v1.19.0
|
159
|
+
git push origin :v1.19.0
|
160
|
+
```
|
161
|
+
|
162
|
+
### Revert the version commit
|
163
|
+
```bash
|
164
|
+
git revert HEAD
|
165
|
+
git push origin master
|
166
|
+
```
|
167
|
+
|
168
|
+
## Example Release Flow
|
169
|
+
|
170
|
+
```bash
|
171
|
+
# 1. Ensure you're on master and up to date
|
172
|
+
git checkout master
|
173
|
+
git pull --rebase
|
174
|
+
|
175
|
+
# 2. Check CI is passing
|
176
|
+
# Visit: https://github.com/shakacode/cypress-playwright-on-rails/actions
|
177
|
+
|
178
|
+
# 3. Release (will handle everything automatically)
|
179
|
+
rake release[1.19.0]
|
180
|
+
# Enter your RubyGems OTP when prompted
|
181
|
+
|
182
|
+
# 4. Update the changelog
|
183
|
+
bundle exec rake update_changelog
|
184
|
+
git commit -a -m 'Update CHANGELOG.md'
|
185
|
+
git push
|
186
|
+
|
187
|
+
# 5. Create GitHub release
|
188
|
+
open "https://github.com/shakacode/cypress-playwright-on-rails/releases"
|
189
|
+
# Click on the new tag, add release notes from CHANGELOG.md
|
190
|
+
|
191
|
+
# 6. Celebrate! 🎉
|
192
|
+
```
|
193
|
+
|
194
|
+
## Notes
|
195
|
+
|
196
|
+
- The release task handles all git operations (commit, tag, push) automatically
|
197
|
+
- Always ensure CI is green before releasing
|
198
|
+
- The task will fail fast if working directory is not clean
|
199
|
+
- Failed releases can be retried after fixing issues
|
200
|
+
- Use dry run mode (`rake release[VERSION,true]`) to preview changes
|
data/Rakefile
CHANGED
data/cypress-on-rails.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency 'railties', '>= 3.2'
|
22
22
|
s.add_development_dependency 'factory_bot', '!= 6.4.5'
|
23
23
|
s.add_development_dependency 'vcr'
|
24
|
+
s.add_development_dependency 'gem-release'
|
24
25
|
s.metadata = {
|
25
26
|
"bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
|
26
27
|
"changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md",
|