Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Changed
* Add support for matching npm package and VCR
* generate for cypress 10 [PR 108](https://github.com/shakacode/cypress-on-rails/pull/108)

## [1.12.1]
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.0...v1.12.1
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bin/rails g cypress_on_rails:update
The generator modifies/adds the following files/directory in your application:
* `config/environments/test.rb`
* `config/initializers/cypress_on_rails` used to configure CypressDev
* `spec/cypress/integrations/` contains your cypress tests
* `spec/cypress/e2e/` contains your cypress tests
* `spec/cypress/support/on-rails.js` contains CypressDev support code
* `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
* `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
Expand Down Expand Up @@ -135,7 +135,7 @@ node_modules/.bin/cypress run
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well

```js
// spec/cypress/integrations/simple_spec.js
// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
Expand Down Expand Up @@ -209,7 +209,7 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
```

```js
// spec/cypress/integrations/simple_spec.js
// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
Expand Down Expand Up @@ -238,7 +238,7 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")

Then reference the scenario in your test:
```js
// spec/cypress/integrations/scenario_example_spec.js
// spec/cypress/e2e/scenario_example.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
Expand All @@ -261,7 +261,7 @@ load "#{Rails.root}/db/seeds.rb"

Then reference the command in your test with `cy.app('load_seed')`:
```js
// spec/cypress/integrations/simple_spec.js
// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
beforeEach(() => { cy.app('load_seed') })

Expand Down
4 changes: 2 additions & 2 deletions lib/cypress-on-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative './cypress_on_rails/railtie' if defined?(Rails)

# maintain backward compatibility
CypressDev = CypressOnRails
Cypress = CypressDev
CypressDev = CypressOnRails unless defined?(CypressDev)
Cypress = CypressDev unless defined?(Cypress)
1 change: 1 addition & 0 deletions lib/cypress_on_rails/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def handle_command(req)
output = {"message" => "Cannot convert to json"}.to_json
end

logger.debug "output: #{output}"
[201, {'Content-Type' => 'application/json'}, [output]]
rescue => e
output = {"message" => e.message, "class" => e.class.to_s}.to_json
Expand Down
9 changes: 2 additions & 7 deletions lib/generators/cypress_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class InstallGenerator < Rails::Generators::Base
class_option :cypress_folder, type: :string, default: 'cypress'
class_option :install_cypress, type: :boolean, default: true
class_option :install_cypress_with, type: :string, default: 'yarn'
class_option :install_cypress_examples, type: :boolean, default: false
class_option :experimental, type: :boolean, default: false
source_root File.expand_path('../templates', __FILE__)

Expand All @@ -23,21 +22,17 @@ def install_cypress
fail 'failed to install cypress' unless system(command)
end
end
if options.install_cypress_examples
directory 'spec/cypress/integration/examples', "#{options.cypress_folder}/integration/examples"
directory 'spec/cypress/fixtures', "#{options.cypress_folder}/fixtures"
end
template "spec/cypress/support/index.js.erb", "#{options.cypress_folder}/support/index.js"
copy_file "spec/cypress/support/commands.js", "#{options.cypress_folder}/support/commands.js"
copy_file "spec/cypress.json", "#{options.cypress_folder}/../cypress.json"
copy_file "spec/cypress.config.js", "#{options.cypress_folder}/../cypress.config.js"
end

def add_initial_files
template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb"
template "spec/cypress/cypress_helper.rb.erb", "#{options.cypress_folder}/cypress_helper.rb"
copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js"
directory 'spec/cypress/app_commands', "#{options.cypress_folder}/app_commands"
directory 'spec/cypress/integration/rails_examples', "#{options.cypress_folder}/integration/rails_examples"
directory 'spec/cypress/e2e/rails_examples', "#{options.cypress_folder}/e2e/rails_examples"
end

def update_files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:5017",
defaultCommandTimeout: 10000,
supportFile: "cypress/support/index.js",
}
})
4 changes: 0 additions & 4 deletions lib/generators/cypress_on_rails/templates/spec/cypress.json

This file was deleted.

This file was deleted.

This file was deleted.

Loading