cypress-on-rails 1.8.1 → 1.9.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/CHANGELOG.md +9 -0
- data/README.md +47 -7
- data/lib/cypress_on_rails/version.rb +1 -1
- data/lib/generators/cypress_on_rails/install_generator.rb +13 -24
- data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +9 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/cypress_helper.rb +7 -2
- data/spec/integrations/rails_3_2/test.sh +1 -1
- data/spec/integrations/rails_4_2/test.sh +1 -1
- data/spec/integrations/rails_5_2/test.sh +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b729d2f84bc4c0ae47bf5604c2f51a8c9c5b793f8256a3e698e127cbb5b54974
|
4
|
+
data.tar.gz: 957791607d573fe7a5d1193df5fc59b7c99f349bf023a71827c2de0dc77e2ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889c0983aeb92cbbbb7cc51ffdb33033bfc33d169bf123483f63b417b522cbdd3e62f1855b4ea36b47d866d6dd2c26fba0e63a939e6e1573640604ee0833cab3
|
7
|
+
data.tar.gz: 1cfabe2cd7c2a39b622aff2c140babd7818050f7289973a4f89d08803906540d78113f4826d1eb07b1f6ebbedc0f334bab3688e2576d375d60a800d9c7197d20
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [1.9.0]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.1...v1.9.0
|
3
|
+
|
4
|
+
### Changed
|
5
|
+
* Update default generated folder to cypress instead of spec/cypress
|
6
|
+
* Add a generator option to not install cypress
|
7
|
+
* generator by default does not include examples
|
8
|
+
* default on local to run cypress in development mode
|
9
|
+
|
1
10
|
## [1.8.1]
|
2
11
|
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.0...v1.8.1
|
3
12
|
|
data/README.md
CHANGED
@@ -8,6 +8,13 @@ This project is sponsored by the software consulting firm [ShakaCode](https://ww
|
|
8
8
|
|
9
9
|
----
|
10
10
|
|
11
|
+
# Totally new to Cypress?
|
12
|
+
Suggest you first learn the basics of Cypress before attempting to integrate with Ruby on Rails
|
13
|
+
|
14
|
+
* [Good start Here](https://docs.cypress.io/examples/examples/tutorials.html#Best-Practices)
|
15
|
+
|
16
|
+
## Overview
|
17
|
+
|
11
18
|
Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and ruby rack applications
|
12
19
|
with the goal of controlling State as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State)
|
13
20
|
|
@@ -28,7 +35,7 @@ Has examples of setting up state with:
|
|
28
35
|
* [Video of getting started with this gem](https://grant-ps.blog/2018/08/10/getting-started-with-cypress-io-and-ruby-on-rails/)
|
29
36
|
* [Article: Introduction to Cypress on Rails](https://www.shakacode.com/blog/introduction-to-cypress-on-rails/)
|
30
37
|
|
31
|
-
##
|
38
|
+
## Installation
|
32
39
|
|
33
40
|
Add this to your Gemfile:
|
34
41
|
|
@@ -43,14 +50,14 @@ Generate the boilerplate code using:
|
|
43
50
|
```shell
|
44
51
|
bin/rails g cypress_on_rails:install
|
45
52
|
|
46
|
-
# if you have/want a different cypress folder (default is
|
47
|
-
bin/rails g cypress_on_rails:install --cypress_folder=
|
53
|
+
# if you have/want a different cypress folder (default is cypress)
|
54
|
+
bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
|
48
55
|
|
49
56
|
# if you want to install cypress with npm
|
50
57
|
bin/rails g cypress_on_rails:install --install_cypress_with=npm
|
51
58
|
|
52
59
|
# if you already have cypress installed globally
|
53
|
-
bin/rails g cypress_on_rails:install --
|
60
|
+
bin/rails g cypress_on_rails:install --no-install-cypress
|
54
61
|
|
55
62
|
# to update the generated files run
|
56
63
|
bin/rails g cypress_on_rails:update
|
@@ -69,24 +76,57 @@ if you are not using factory_bot look at `spec/cypress/app_commands/factory_bot.
|
|
69
76
|
|
70
77
|
Now you can create scenarios and commands that are plain ruby files that get loaded through middleware, the ruby sky is your limit.
|
71
78
|
|
79
|
+
### Update your database.yml
|
80
|
+
|
81
|
+
When writing cypress test on your local it's recommended to start your server in development mode so that changes you
|
82
|
+
make are picked up without having to restart the server.
|
83
|
+
It's recommend you update your database.yml to check if the CYPRESS environment variable is set and switch it to the test database
|
84
|
+
otherwise cypress will keep clearing your development database.
|
85
|
+
|
86
|
+
for example:
|
87
|
+
|
88
|
+
```yaml
|
89
|
+
development:
|
90
|
+
<<: *default
|
91
|
+
database: <%= ENV['CYPRESS'] ? 'my_db_test' : 'my_db_development' %>
|
92
|
+
test:
|
93
|
+
<<: *default
|
94
|
+
database: my_db_test
|
95
|
+
```
|
96
|
+
|
72
97
|
### WARNING
|
73
98
|
*WARNING!!:* cypress-on-rails can execute arbitrary ruby code
|
74
99
|
Please use with extra caution if starting your local server on 0.0.0.0 or running the gem on a hosted server
|
75
100
|
|
76
101
|
## Usage
|
77
102
|
|
78
|
-
|
103
|
+
Getting started on your local environment
|
79
104
|
|
80
105
|
```shell
|
81
106
|
# start rails
|
82
|
-
|
83
|
-
bin/rails server -e test -p 5017
|
107
|
+
CYPRESS=1 bin/rails server -p 5017
|
84
108
|
|
85
109
|
# in separate window start cypress
|
110
|
+
yarn cypress open
|
111
|
+
# or for npm
|
112
|
+
node_modules/.bin/cypress open
|
113
|
+
# or if you changed the cypress folder to spec/cypress
|
86
114
|
yarn cypress open --project ./spec
|
87
115
|
```
|
88
116
|
|
117
|
+
How to run cypress on CI
|
118
|
+
|
119
|
+
```shell
|
120
|
+
# setup rails and start server in background
|
121
|
+
# ...
|
122
|
+
|
123
|
+
yarn run cypress run
|
124
|
+
# or for npm
|
125
|
+
node_modules/.bin/cypress run
|
126
|
+
```
|
127
|
+
|
89
128
|
### Example of using factory bot
|
129
|
+
|
90
130
|
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
|
91
131
|
|
92
132
|
```ruby
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module CypressOnRails
|
2
2
|
class InstallGenerator < Rails::Generators::Base
|
3
|
-
class_option :cypress_folder, type: :string, default: '
|
3
|
+
class_option :cypress_folder, type: :string, default: 'cypress'
|
4
|
+
class_option :install_cypress, type: :boolean, default: true
|
4
5
|
class_option :install_cypress_with, type: :string, default: 'yarn'
|
5
|
-
class_option :install_cypress_examples, type: :boolean, default:
|
6
|
+
class_option :install_cypress_examples, type: :boolean, default: false
|
6
7
|
source_root File.expand_path('../templates', __FILE__)
|
7
8
|
|
8
9
|
def install_cypress
|
@@ -11,14 +12,16 @@ module CypressOnRails
|
|
11
12
|
directories.pop
|
12
13
|
install_dir = "#{Dir.pwd}/#{directories.join('/')}"
|
13
14
|
command = nil
|
14
|
-
if options.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
if options.install_cypress
|
16
|
+
if options.install_cypress_with == 'yarn'
|
17
|
+
command = "yarn --cwd=#{install_dir} add cypress --dev"
|
18
|
+
elsif options.install_cypress_with == 'npm'
|
19
|
+
command = "cd #{install_dir}; npm install cypress --save-dev"
|
20
|
+
end
|
21
|
+
if command
|
22
|
+
say command
|
23
|
+
fail 'failed to install cypress' unless system(command)
|
24
|
+
end
|
22
25
|
end
|
23
26
|
if options.install_cypress_examples
|
24
27
|
directory 'spec/cypress/integration/examples', "#{options.cypress_folder}/integration/examples"
|
@@ -43,19 +46,5 @@ module CypressOnRails
|
|
43
46
|
"\nimport './on-rails'",
|
44
47
|
after: 'import \'./commands\''
|
45
48
|
end
|
46
|
-
|
47
|
-
|
48
|
-
def update_test_rb
|
49
|
-
if File.exist?('config/environments/test.rb')
|
50
|
-
gsub_file 'config/environments/test.rb',
|
51
|
-
'config.cache_classes = true',
|
52
|
-
'config.cache_classes = ENV[\'CI\'].present?'
|
53
|
-
end
|
54
|
-
if File.exist?('spec/dummy/config/environments/test.rb')
|
55
|
-
gsub_file 'spec/dummy/config/environments/test.rb',
|
56
|
-
'config.cache_classes = true',
|
57
|
-
'config.cache_classes = ENV[\'CI\'].present?'
|
58
|
-
end
|
59
|
-
end
|
60
49
|
end
|
61
50
|
end
|
@@ -3,7 +3,15 @@ if defined?(CypressOnRails)
|
|
3
3
|
c.cypress_folder = File.expand_path("#{__dir__}/../../<%= options.cypress_folder %>")
|
4
4
|
# WARNING!! CypressOnRails can execute arbitrary ruby code
|
5
5
|
# please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0
|
6
|
-
c.use_middleware = Rails.env.
|
6
|
+
c.use_middleware = !Rails.env.production?
|
7
7
|
c.logger = Rails.logger
|
8
8
|
end
|
9
|
+
|
10
|
+
# # if you compile your asssets on CI
|
11
|
+
# if ENV['CYPRESS'].present? && ENV['CI'].present?
|
12
|
+
# Rails.application.configure do
|
13
|
+
# config.assets.compile = false
|
14
|
+
# config.assets.unknown_asset_fallback = false
|
15
|
+
# end
|
16
|
+
# end
|
9
17
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
# This is loaded once before the first command is executed
|
2
2
|
|
3
3
|
begin
|
4
|
-
|
4
|
+
require 'database_cleaner-active_record'
|
5
5
|
rescue LoadError => e
|
6
|
-
|
6
|
+
puts e.message
|
7
|
+
begin
|
8
|
+
require 'database_cleaner'
|
9
|
+
rescue LoadError => e
|
10
|
+
puts e.message
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
14
|
begin
|
@@ -14,7 +14,7 @@ bundle --version
|
|
14
14
|
bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
|
15
15
|
|
16
16
|
echo '-- cypress install'
|
17
|
-
bundle exec ./bin/rails g cypress_on_rails:install --
|
17
|
+
bundle exec ./bin/rails g cypress_on_rails:install --install_cypress_with=npm
|
18
18
|
rm -vf cypress/integration/rails_examples/advance_factory_bot_spec.js
|
19
19
|
|
20
20
|
echo '-- start rails server'
|
@@ -14,7 +14,7 @@ bundle --version
|
|
14
14
|
bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
|
15
15
|
|
16
16
|
echo '-- cypress install'
|
17
|
-
bundle exec ./bin/rails g cypress_on_rails:install --
|
17
|
+
bundle exec ./bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
|
18
18
|
rm -vf spec/cypress/integration/rails_examples/advance_factory_bot_spec.js
|
19
19
|
|
20
20
|
echo '-- start rails server'
|
@@ -14,7 +14,8 @@ bundle --version
|
|
14
14
|
bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
|
15
15
|
|
16
16
|
echo '-- migration'
|
17
|
-
bin/rails db:
|
17
|
+
bundle exec ./bin/rails db:drop || true
|
18
|
+
bundle exec ./bin/rails db:create db:migrate
|
18
19
|
|
19
20
|
echo '-- cypress install'
|
20
21
|
bundle exec ./bin/rails g cypress_on_rails:install --cypress_folder=test/cypress --no-install-cypress-examples
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cypress-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miceportal team
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -323,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
323
|
- !ruby/object:Gem::Version
|
324
324
|
version: '0'
|
325
325
|
requirements: []
|
326
|
-
rubygems_version: 3.2.
|
326
|
+
rubygems_version: 3.2.11
|
327
327
|
signing_key:
|
328
328
|
specification_version: 4
|
329
329
|
summary: Integrates cypress with rails or rack applications
|