Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/generators/cypress_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def install_framework

def add_initial_files
template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb"
template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/#{options.framework}/e2e_helper.rb"
directory 'spec/e2e/app_commands', "#{options.install_folder}/#{options.framework}/app_commands"
template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/e2e_helper.rb"
directory 'spec/e2e/app_commands', "#{options.install_folder}/app_commands"
if options.framework == 'cypress'
copy_file "spec/cypress/support/on-rails.js", "#{options.install_folder}/cypress/support/on-rails.js"
directory 'spec/cypress/e2e/rails_examples', "#{options.install_folder}/cypress/e2e/rails_examples"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if defined?(CypressOnRails)
CypressOnRails.configure do |c|
c.api_prefix = "<%= options.api_prefix %>"
c.install_folder = File.expand_path("#{__dir__}/../../<%= options.install_folder %>/<%= options.framework %>")
c.install_folder = File.expand_path("#{__dir__}/../../<%= options.install_folder %>")
# WARNING!! CypressOnRails can execute arbitrary ruby code
# please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0
c.use_middleware = !Rails.env.production?
Expand All @@ -12,7 +12,7 @@ if defined?(CypressOnRails)
<% unless options.experimental %># <% end %> c.vcr_options = {
<% unless options.experimental %># <% end %> hook_into: :webmock,
<% unless options.experimental %># <% end %> default_cassette_options: { record: :once },
<% unless options.experimental %># <% end %> cassette_library_dir: File.expand_path("#{__dir__}/../../<%= options.install_folder %>/<%= options.framework %>/fixtures/vcr_cassettes")
<% unless options.experimental %># <% end %> cassette_library_dir: File.expand_path("#{__dir__}/../../<%= options.install_folder %>/fixtures/vcr_cassettes")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

VCR cassettes now shared across frameworks.

The cassette_library_dir path change moves VCR cassettes from framework-specific directories (e.g., e2e/cypress/fixtures/vcr_cassettes) to a shared location (e2e/fixtures/vcr_cassettes). Since VCR cassettes record framework-agnostic HTTP interactions, this sharing is logical and reduces duplication.

Verify that cassette sharing works correctly across frameworks:


🏁 Script executed:

#!/bin/bash
# Description: Check for any code that might expect framework-specific cassette paths

# Search for VCR cassette path references
echo "=== Checking VCR cassette path usage ==="
rg -n -A3 -B3 'vcr_cassettes|cassette_library_dir' --type=rb

# Look for framework-specific fixture paths
echo -e "\n=== Checking for framework-specific fixture references ==="
rg -n 'fixtures.*cypress|fixtures.*playwright' --type=rb

Length of output: 154


🏁 Script executed:

#!/bin/bash
echo "=== Checking VCR cassette path usage ==="
rg -n -A3 -B3 'cassette_library_dir|vcr_cassettes'

echo
echo "=== Checking for framework-specific fixture references ==="
rg -n -C3 'cypress/fixtures/vcr_cassettes'
rg -n -C3 'playwright/fixtures/vcr_cassettes'

Length of output: 7365


Update README.md example for cassette_library_dir
Replace the framework-specific path in README.md (line 452)

- cassette_library_dir: File.expand_path("#{__dir__}/../../spec/cypress/fixtures/vcr_cassettes")
+ cassette_library_dir: File.expand_path("#{__dir__}/../../spec/fixtures/vcr_cassettes")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<% unless options.experimental %># <% end %> cassette_library_dir: File.expand_path("#{__dir__}/../../<%= options.install_folder %>/fixtures/vcr_cassettes")
cassette_library_dir: File.expand_path("#{__dir__}/../../spec/fixtures/vcr_cassettes")
🤖 Prompt for AI Agents
In
lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb
around line 15, the template uses a generic cassette_library_dir that references
the install_folder; update README.md (around line 452) to replace the current
framework-specific cassette path with the generic form used in the template so
it points to the fixtures/vcr_cassettes under the gem/install folder (i.e.,
remove framework-specific directory names and use the relative path pattern that
mirrors the template's install_folder location).

<% unless options.experimental %># <% end %> }
c.logger = Rails.logger

Expand Down