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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ VCR.turn_off!
WebMock.disable! if defined?(WebMock)
```

Add to you `config/cypress_on_rails.rb`

```ruby
c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
```

#### usage

You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette
Expand Down
3 changes: 3 additions & 0 deletions lib/cypress_on_rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ module CypressOnRails
class Configuration
attr_accessor :cypress_folder
attr_accessor :use_middleware
attr_accessor :use_vcr_middleware
attr_accessor :logger

def initialize
reset
end

alias :use_middleware? :use_middleware
alias :use_vcr_middleware? :use_vcr_middleware

def reset
self.cypress_folder = 'spec/cypress'
self.use_middleware = true
self.use_vcr_middleware = true

Choose a reason for hiding this comment

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

given that the feature is considered experimental, shouldn't this default to false?

as it is right now, the release of v1.13.0 breaks our test suite because the middleware also turn off VCR in rspec..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, you right 👍🏽. Will get it fixed

self.logger = Logger.new(STDOUT)
end

Expand Down
2 changes: 2 additions & 0 deletions lib/cypress_on_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Railtie < Rails::Railtie
if CypressOnRails.configuration.use_middleware?
require 'cypress_on_rails/middleware'
app.middleware.use Middleware
end
if CypressOnRails.configuration.use_vcr_middleware?
require 'cypress_on_rails/vcr_middleware'
app.middleware.use VCRMiddleware
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if defined?(CypressOnRails)
# 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?
<% unless options.experimental %># <% end %> c.use_vcr_middleware = !Rails.env.production?
c.logger = Rails.logger
end

Expand Down