Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Run RuboCop
run: bundle exec rubocop

- name: Check for files missing newlines
run: bundle exec rake check_newlines
76 changes: 76 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require:
- rubocop-rake
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
- 'pkg/**/*'
- 'node_modules/**/*'
- 'specs_e2e/**/*'
- 'e2e/**/*'

# Ensure all files end with a newline
Layout/TrailingEmptyLines:
Enabled: true
EnforcedStyle: final_newline

# Ensure no trailing whitespace
Layout/TrailingWhitespace:
Enabled: true

# Line length - be reasonable but not too strict
Layout/LineLength:
Max: 120
Exclude:
- 'spec/**/*'
- 'lib/generators/**/*'

# Allow longer blocks in specs and rake tasks
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- '**/*.rake'
- 'Rakefile'
- '*.gemspec'

# Allow longer methods in rake tasks
Metrics/MethodLength:
Exclude:
- '**/*.rake'
- 'Rakefile'

# String literals
Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes
ConsistentQuotesInMultiline: true

# Frozen string literal pragma
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Exclude:
- 'spec/**/*'

# Documentation
Style/Documentation:
Enabled: false

# Allow compact module/class definitions
Style/ClassAndModuleChildren:
Enabled: false

# RSpec specific
RSpec/ExampleLength:
Max: 20

RSpec/MultipleExpectations:
Max: 5

RSpec/NestedGroups:
Max: 4
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
source 'http://rubygems.org'
gemspec

2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ open "https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=
- Always review changes before committing
- The `publish` task will run tests before releasing
- Tags are created locally first, then pushed
- Failed releases can be retried after fixing issues
- Failed releases can be retried after fixing issues
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require 'bundler/gem_tasks'
# frozen_string_literal: true

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/cypress_on_rails/*_spec.rb'
end

task default: %w[spec build]
desc 'Run all CI checks (specs, linting, newlines)'
task ci: %i[spec lint check_newlines]

task default: :ci
50 changes: 50 additions & 0 deletions bin/install-hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'

hooks_dir = File.expand_path('../.git/hooks', __dir__)
pre_commit_hook = File.join(hooks_dir, 'pre-commit')

# Create pre-commit hook content
hook_content = <<~HOOK
#!/bin/sh
# Pre-commit hook to run linters and check for newlines

# Check for files missing newlines
echo "Checking for files missing newlines..."
bundle exec rake check_newlines
if [ $? -ne 0 ]; then
echo "❌ Some files are missing final newlines. Run 'bundle exec rake fix_newlines' to fix."
exit 1
fi

# Run RuboCop on staged Ruby files
echo "Running RuboCop on staged files..."
files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\\.(rb|rake)$')
if [ -n "$files" ]; then
bundle exec rubocop $files
if [ $? -ne 0 ]; then
echo "❌ RuboCop failed. Fix issues or run 'bundle exec rake lint:fix'"
exit 1
fi
fi

echo "✅ All checks passed!"
HOOK

# Create hooks directory if it doesn't exist
FileUtils.mkdir_p(hooks_dir)

# Write the pre-commit hook
File.write(pre_commit_hook, hook_content)

# Make it executable
File.chmod(0o755, pre_commit_hook)

puts '✅ Pre-commit hook installed successfully!'
puts 'The hook will:'
puts ' - Check that all files end with a newline'
puts ' - Run RuboCop on staged Ruby files'
puts ''
puts 'To skip the hook temporarily, use: git commit --no-verify'
42 changes: 22 additions & 20 deletions cypress-on-rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "cypress_on_rails/version"
$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'cypress_on_rails/version'

Gem::Specification.new do |s|
s.name = "cypress-on-rails"
s.name = 'cypress-on-rails'
s.version = CypressOnRails::VERSION
s.author = ["miceportal team", 'Grant Petersen-Speelman']
s.email = ["[email protected]", '[email protected]']
s.homepage = "http://github.com/shakacode/cypress-on-rails"
s.summary = "Integrates cypress with rails or rack applications"
s.description = "Integrates cypress with rails or rack applications"
s.author = ['miceportal team', 'Grant Petersen-Speelman']
s.email = ['[email protected]', '[email protected]']
s.homepage = 'http://github.com/shakacode/cypress-on-rails'
s.summary = 'Integrates cypress with rails or rack applications'
s.description = 'Integrates cypress with rails or rack applications'
s.post_install_message = 'The CypressDev constant is being deprecated and will be completely removed and replaced with CypressOnRails.'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ["lib"]
s.require_paths = ['lib']
s.add_dependency 'rack'
s.add_development_dependency 'factory_bot', '!= 6.4.5'
s.add_development_dependency 'gem-release'
s.add_development_dependency 'railties', '>= 3.2'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'railties', '>= 3.2'
s.add_development_dependency 'factory_bot', '!= 6.4.5'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'rubocop-rake'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'vcr'
s.add_development_dependency 'gem-release'
s.metadata = {
"bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
"changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md",
"documentation_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/README.md",
"homepage_uri" => "http://github.com/shakacode/cypress-on-rails",
"source_code_uri" => "http://github.com/shakacode/cypress-on-rails"
}
'bug_tracker_uri' => 'https://github.com/shakacode/cypress-on-rails/issues',
'changelog_uri' => 'https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md',
'documentation_uri' => 'https://github.com/shakacode/cypress-on-rails/blob/master/README.md',
'homepage_uri' => 'http://github.com/shakacode/cypress-on-rails',
'source_code_uri' => 'http://github.com/shakacode/cypress-on-rails',
'rubygems_mfa_required' => 'true'
}
end
2 changes: 1 addition & 1 deletion docs/BEST_PRACTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,4 @@ Following these best practices will help you:
- Secure your test infrastructure
- Debug issues more effectively

Remember: E2E tests should focus on critical user journeys. Use unit and integration tests for comprehensive coverage of edge cases.
Remember: E2E tests should focus on critical user journeys. Use unit and integration tests for comprehensive coverage of edge cases.
2 changes: 1 addition & 1 deletion docs/DX_IMPROVEMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ To continue improving developer experience:

## Conclusion

These documentation and feature improvements directly address the most common pain points users face. By providing comprehensive guides, troubleshooting resources, and automated solutions, we've significantly improved the developer experience for both new and existing users of cypress-playwright-on-rails.
These documentation and feature improvements directly address the most common pain points users face. By providing comprehensive guides, troubleshooting resources, and automated solutions, we've significantly improved the developer experience for both new and existing users of cypress-playwright-on-rails.
2 changes: 1 addition & 1 deletion docs/PLAYWRIGHT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,4 @@ test('debug this', async ({ page }, testInfo) => {
View traces:
```bash
npx playwright show-trace trace-debug-this.zip
```
```
2 changes: 1 addition & 1 deletion docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,4 @@ If you encounter issues not covered here:
- Your Rails version
- cypress-on-rails version
- Minimal reproduction steps
- Full error messages and stack traces
- Full error messages and stack traces
2 changes: 1 addition & 1 deletion docs/VCR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,4 @@ Remember to:
- Configure VCR appropriately for your needs
- Filter sensitive data
- Organize cassettes logically
- Keep cassettes up to date
- Keep cassettes up to date
2 changes: 1 addition & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ Examples of usage in Playwright specs:
```js
await forceLogin(page, { email: '[email protected]', redirect_to: '/profile' });

```
```
2 changes: 1 addition & 1 deletion lib/cypress-on-rails.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'cypress_on_rails/version'
require 'cypress_on_rails/configuration'
require_relative './cypress_on_rails/railtie' if defined?(Rails)
require_relative 'cypress_on_rails/railtie' if defined?(Rails)

# maintain backward compatibility
CypressDev = CypressOnRails unless defined?(CypressDev)
Expand Down
2 changes: 1 addition & 1 deletion lib/cypress/smart_factory_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require 'cypress-on-rails'
require 'cypress_on_rails/smart_factory_wrapper'
# for backward compatibility
# for backward compatibility
2 changes: 1 addition & 1 deletion lib/cypress_dev/middleware.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
warn "cypress_dev is being deprecated, please require \"cypress_on_rails/middleware\" instead"
warn 'cypress_dev is being deprecated, please require "cypress_on_rails/middleware" instead'
require 'cypress_on_rails/middleware'
2 changes: 1 addition & 1 deletion lib/cypress_dev/smart_factory_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
warn "cypress_dev is being deprecated, please require \"cypress_on_rails/smart_factory_wrapper\" instead"
warn 'cypress_dev is being deprecated, please require "cypress_on_rails/smart_factory_wrapper" instead'
require 'cypress_on_rails/smart_factory_wrapper'
6 changes: 3 additions & 3 deletions lib/cypress_on_rails/command_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
module CypressOnRails
# loads and evals the command files
class CommandExecutor
def self.perform(file,command_options = nil)
def self.perform(file, command_options = nil)
load_e2e_helper
file_data = File.read(file)
eval file_data, binding, file
rescue => e
rescue StandardError => e
logger.error("fail to execute #{file}: #{e.message}")
logger.error(e.backtrace.join("\n"))
raise e
Expand All @@ -20,7 +20,7 @@ def self.load_e2e_helper
Kernel.require e2e_helper_file
elsif File.exist?(cypress_helper_file)
Kernel.require cypress_helper_file
warn "cypress_helper.rb is deprecated, please rename the file to e2e_helper.rb"
warn 'cypress_helper.rb is deprecated, please rename the file to e2e_helper.rb'
else
logger.warn "could not find #{e2e_helper_file} nor #{cypress_helper_file}"
end
Expand Down
Loading
Loading