cypress-on-rails 1.6.0 → 1.9.1
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 +5 -5
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +45 -0
- data/README.md +55 -9
- data/cypress-on-rails.gemspec +9 -1
- data/lib/cypress_on_rails/command_executor.rb +2 -2
- data/lib/cypress_on_rails/middleware.rb +1 -1
- data/lib/cypress_on_rails/railtie.rb +1 -1
- data/lib/cypress_on_rails/simple_rails_factory.rb +4 -0
- data/lib/cypress_on_rails/smart_factory_wrapper.rb +3 -13
- 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/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js +3 -3
- data/spec/cypress_on_rails/command_executor_spec.rb +7 -7
- data/spec/cypress_on_rails/middleware_spec.rb +10 -10
- data/spec/cypress_on_rails/smart_factory_wrapper_spec.rb +13 -12
- 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 +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df550a0ca15f4fe35c0bdf3227596ea79e6cbb9c407117592383466c81f45447
|
4
|
+
data.tar.gz: 6dc7c397f9e13dd6ad7f60e5d0bb929bb1aa0a65dab9ed5992f1d260686316ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd12f10387af1cd51f91e65acea0b2705970487e101fe963273a70982c0f789a00896bab78ea461a2fee1dab3e1aa63be8d0e9d45e8ab39b8bee7b0c3821a5cb
|
7
|
+
data.tar.gz: dbf5569c5d5b71bd737b28f656f2c9993a0235ebc9e87c8f42def465521900c713fa9ffe33035b5603d00796c7c6bae39941e36f261b17266159567addf470ff
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: [shakacode]
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -26,6 +26,9 @@ before_install:
|
|
26
26
|
- sudo apt-get -qq update
|
27
27
|
- sudo apt-get install -y build-essential patch ruby-dev zlib1g-dev liblzma-dev libxml2-dev
|
28
28
|
- sudo apt-get install -y xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
|
29
|
+
- travis_retry nvm install 14.13.1
|
30
|
+
- node -v
|
31
|
+
- nvm alias default 14.13.1
|
29
32
|
|
30
33
|
script:
|
31
34
|
- bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
## [1.9.1]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.0...v1.9.1
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
* fix using `load` in command files
|
6
|
+
|
7
|
+
## [1.9.0]
|
8
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.1...v1.9.0
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
* Update default generated folder to cypress instead of spec/cypress
|
12
|
+
* Add a generator option to not install cypress
|
13
|
+
* generator by default does not include examples
|
14
|
+
* default on local to run cypress in development mode
|
15
|
+
|
16
|
+
## [1.8.1]
|
17
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.0...v1.8.1
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
* remove "--silent" option when adding cypress [PR 76](https://github.com/shakacode/cypress-on-rails/pull/76)
|
21
|
+
* update cypress examples to use "preserve" instead of "whitelist" [PR 75](https://github.com/shakacode/cypress-on-rails/pull/75) by [alvincrespo](https://github.com/alvincrespo)
|
22
|
+
|
23
|
+
## [1.8.0]
|
24
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.7.0...v1.8.0
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
* Use `FactoryBo#reload` to reset factory bot
|
28
|
+
|
29
|
+
## [1.7.0]
|
30
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.6.0...v1.7.0
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
* Improve eval() in command executor [PR 46](https://github.com/shakacode/cypress-on-rails/pull/46) by [Systho](https://github.com/Systho)
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
* Add middleware after load_config_initializers [PR 62](https://github.com/shakacode/cypress-on-rails/pull/62) by [duytd](https://github.com/duytd)
|
37
|
+
|
1
38
|
## [1.6.0]
|
2
39
|
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.1...v1.6.0
|
3
40
|
|
@@ -107,6 +144,14 @@
|
|
107
144
|
## 0.1.2 (2017-10-31)
|
108
145
|
* First release.
|
109
146
|
|
147
|
+
[1.8.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.7.0...v1.8.0
|
148
|
+
[1.7.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.6.0...v1.7.0
|
149
|
+
[1.6.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.1...v1.6.0
|
150
|
+
[1.5.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.0...v1.5.1
|
151
|
+
[1.5.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.2...v1.5.0
|
152
|
+
[1.4.2]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.1...v1.4.2
|
153
|
+
[1.4.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.0...v1.4.1
|
154
|
+
[1.4.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.3.0...v1.4.0
|
110
155
|
[1.3.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.1...v1.3.0
|
111
156
|
[1.2.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.0...v1.2.1
|
112
157
|
[1.2.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.1.1...v1.2.0
|
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
|
|
@@ -24,9 +31,11 @@ Has examples of setting up state with:
|
|
24
31
|
* scenarios
|
25
32
|
* custom commands
|
26
33
|
|
27
|
-
|
34
|
+
## Resources
|
35
|
+
* [Video of getting started with this gem](https://grant-ps.blog/2018/08/10/getting-started-with-cypress-io-and-ruby-on-rails/)
|
36
|
+
* [Article: Introduction to Cypress on Rails](https://www.shakacode.com/blog/introduction-to-cypress-on-rails/)
|
28
37
|
|
29
|
-
##
|
38
|
+
## Installation
|
30
39
|
|
31
40
|
Add this to your Gemfile:
|
32
41
|
|
@@ -41,12 +50,15 @@ Generate the boilerplate code using:
|
|
41
50
|
```shell
|
42
51
|
bin/rails g cypress_on_rails:install
|
43
52
|
|
44
|
-
# if you have/want a different cypress folder (default is
|
45
|
-
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
|
46
55
|
|
47
56
|
# if you want to install cypress with npm
|
48
57
|
bin/rails g cypress_on_rails:install --install_cypress_with=npm
|
49
58
|
|
59
|
+
# if you already have cypress installed globally
|
60
|
+
bin/rails g cypress_on_rails:install --no-install-cypress
|
61
|
+
|
50
62
|
# to update the generated files run
|
51
63
|
bin/rails g cypress_on_rails:update
|
52
64
|
```
|
@@ -64,24 +76,57 @@ if you are not using factory_bot look at `spec/cypress/app_commands/factory_bot.
|
|
64
76
|
|
65
77
|
Now you can create scenarios and commands that are plain ruby files that get loaded through middleware, the ruby sky is your limit.
|
66
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
|
+
|
67
97
|
### WARNING
|
68
98
|
*WARNING!!:* cypress-on-rails can execute arbitrary ruby code
|
69
99
|
Please use with extra caution if starting your local server on 0.0.0.0 or running the gem on a hosted server
|
70
100
|
|
71
101
|
## Usage
|
72
102
|
|
73
|
-
|
103
|
+
Getting started on your local environment
|
74
104
|
|
75
105
|
```shell
|
76
106
|
# start rails
|
77
|
-
|
78
|
-
bin/rails server -e test -p 5017
|
107
|
+
CYPRESS=1 bin/rails server -p 5017
|
79
108
|
|
80
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
|
81
114
|
yarn cypress open --project ./spec
|
82
115
|
```
|
83
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
|
+
|
84
128
|
### Example of using factory bot
|
129
|
+
|
85
130
|
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
|
86
131
|
|
87
132
|
```ruby
|
@@ -102,7 +147,8 @@ describe('My First Test', function() {
|
|
102
147
|
// This calls to the backend to prepare the application state
|
103
148
|
cy.appFactories([
|
104
149
|
['create_list', 'post', 10],
|
105
|
-
['create', 'post', {title: 'Hello World'} ]
|
150
|
+
['create', 'post', {title: 'Hello World'} ],
|
151
|
+
['create', 'post', 'with_comments', {title: 'Factory_bot Traits here'} ] // use traits
|
106
152
|
])
|
107
153
|
|
108
154
|
// Visit the application under test
|
@@ -249,7 +295,7 @@ beforeEach(() => {
|
|
249
295
|
|
250
296
|
## Contributing
|
251
297
|
|
252
|
-
1. Fork it ( https://github.com/
|
298
|
+
1. Fork it ( https://github.com/shakacode/cypress-on-rails/fork )
|
253
299
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
254
300
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
255
301
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/cypress-on-rails.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = CypressOnRails::VERSION
|
8
8
|
s.author = ["miceportal team", 'Grant Petersen-Speelman']
|
9
9
|
s.email = ["info@miceportal.de", 'grantspeelman@gmail.com']
|
10
|
-
s.homepage = "http://github.com/
|
10
|
+
s.homepage = "http://github.com/shakacode/cypress-on-rails"
|
11
11
|
s.summary = "Integrates cypress with rails or rack applications"
|
12
12
|
s.description = "Integrates cypress with rails or rack applications"
|
13
13
|
s.post_install_message = 'The CypressDev constant is being deprecated and will be completely removed and replaced with CypressOnRails.'
|
@@ -19,4 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency 'rake'
|
20
20
|
s.add_development_dependency 'rspec'
|
21
21
|
s.add_development_dependency 'railties', '>= 3.2'
|
22
|
+
s.add_development_dependency 'factory_bot'
|
23
|
+
s.metadata = {
|
24
|
+
"bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
|
25
|
+
"changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md",
|
26
|
+
"documentation_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/README.md",
|
27
|
+
"homepage_uri" => "http://github.com/shakacode/cypress-on-rails",
|
28
|
+
"source_code_uri" => "http://github.com/shakacode/cypress-on-rails"
|
29
|
+
}
|
22
30
|
end
|
@@ -3,10 +3,10 @@ require 'cypress_on_rails/configuration'
|
|
3
3
|
module CypressOnRails
|
4
4
|
# loads and evals the command files
|
5
5
|
class CommandExecutor
|
6
|
-
def self.
|
6
|
+
def self.perform(file,command_options = nil)
|
7
7
|
load_cypress_helper
|
8
8
|
file_data = File.read(file)
|
9
|
-
eval file_data
|
9
|
+
eval file_data, binding, file
|
10
10
|
rescue => e
|
11
11
|
logger.error("fail to execute #{file}: #{e.message}")
|
12
12
|
logger.error(e.backtrace.join("\n"))
|
@@ -56,7 +56,7 @@ module CypressOnRails
|
|
56
56
|
missing_command = commands.find {|command| !@file.exists?(command.file_path) }
|
57
57
|
|
58
58
|
if missing_command.nil?
|
59
|
-
results = commands.map { |command| @command_executor.
|
59
|
+
results = commands.map { |command| @command_executor.perform(command.file_path, command.options) }
|
60
60
|
|
61
61
|
begin
|
62
62
|
output = results.to_json
|
@@ -4,7 +4,7 @@ require 'cypress_on_rails/middleware'
|
|
4
4
|
|
5
5
|
module CypressOnRails
|
6
6
|
class Railtie < Rails::Railtie
|
7
|
-
initializer :setup_cypress_middleware do |app|
|
7
|
+
initializer :setup_cypress_middleware, after: :load_config_initializers do |app|
|
8
8
|
if CypressOnRails.configuration.use_middleware?
|
9
9
|
app.middleware.use Middleware
|
10
10
|
end
|
@@ -3,15 +3,6 @@ require 'cypress_on_rails/simple_rails_factory'
|
|
3
3
|
|
4
4
|
module CypressOnRails
|
5
5
|
class SmartFactoryWrapper
|
6
|
-
module FactoryCleaner
|
7
|
-
def self.clean(f = FactoryBot)
|
8
|
-
f.factories.clear if f.respond_to?(:factories)
|
9
|
-
f.traits.clear if f.respond_to?(:traits)
|
10
|
-
f.callbacks.clear if f.respond_to?(:callbacks)
|
11
|
-
f.sequences.clear if f.respond_to?(:sequences)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
6
|
def self.instance
|
16
7
|
@instance ||= new(files: [], factory: SimpleRailsFactory)
|
17
8
|
end
|
@@ -33,14 +24,13 @@ module CypressOnRails
|
|
33
24
|
attr_accessor :always_reload
|
34
25
|
|
35
26
|
def initialize(files:, factory:, always_reload: false,
|
36
|
-
|
37
|
-
dir_system: Dir)
|
27
|
+
kernel: Kernel, file_system: File, dir_system: Dir)
|
38
28
|
self.files = files
|
39
29
|
self.factory = factory
|
30
|
+
factory.definition_file_paths = []
|
40
31
|
self.always_reload = always_reload
|
41
32
|
@kernel = kernel
|
42
33
|
@file_system = file_system
|
43
|
-
@factory_cleaner = factory_cleaner
|
44
34
|
@latest_mtime = nil
|
45
35
|
@dir_system = dir_system
|
46
36
|
end
|
@@ -83,7 +73,7 @@ module CypressOnRails
|
|
83
73
|
return unless should_reload?(current_latest_mtime)
|
84
74
|
logger.info 'Loading Factories'
|
85
75
|
@latest_mtime = current_latest_mtime
|
86
|
-
|
76
|
+
factory.reload
|
87
77
|
files.each do |file|
|
88
78
|
logger.debug "-- Loading: #{file}"
|
89
79
|
@kernel.load(file)
|
@@ -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
|
data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js
CHANGED
@@ -65,7 +65,7 @@ context('Cypress.Cookies', () => {
|
|
65
65
|
// now any cookie with the name 'session_id' will
|
66
66
|
// not be cleared before each new test runs
|
67
67
|
Cypress.Cookies.defaults({
|
68
|
-
|
68
|
+
preserve: 'session_id',
|
69
69
|
})
|
70
70
|
})
|
71
71
|
})
|
@@ -84,8 +84,8 @@ context('Cypress.Server', () => {
|
|
84
84
|
Cypress.Server.defaults({
|
85
85
|
delay: 0,
|
86
86
|
force404: false,
|
87
|
-
|
88
|
-
// handle custom logic for
|
87
|
+
preserve (xhr) {
|
88
|
+
// handle custom logic for preserving
|
89
89
|
},
|
90
90
|
})
|
91
91
|
})
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'cypress_on_rails/command_executor'
|
2
2
|
|
3
3
|
RSpec.describe CypressOnRails::CommandExecutor do
|
4
|
-
describe '.
|
4
|
+
describe '.perform' do
|
5
5
|
let(:folder) { "#{__dir__}/command_executor" }
|
6
6
|
subject { described_class }
|
7
7
|
|
8
|
-
def
|
9
|
-
subject.
|
8
|
+
def executor_perform(*values)
|
9
|
+
subject.perform(*values)
|
10
10
|
end
|
11
11
|
|
12
12
|
before do
|
@@ -15,18 +15,18 @@ RSpec.describe CypressOnRails::CommandExecutor do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'runs test command' do
|
18
|
-
|
18
|
+
executor_perform("#{folder}/test_command.rb")
|
19
19
|
expect(DummyTest.values).to eq(%w(hello))
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'runs test command twice' do
|
23
|
-
|
24
|
-
|
23
|
+
executor_perform("#{folder}/test_command.rb")
|
24
|
+
executor_perform("#{folder}/test_command.rb")
|
25
25
|
expect(DummyTest.values).to eq(%w(hello hello))
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'runs command with options' do
|
29
|
-
|
29
|
+
executor_perform("#{folder}/test_command_with_options.rb", 'my_string')
|
30
30
|
expect(DummyTest.values).to eq(%w(my_string))
|
31
31
|
end
|
32
32
|
end
|
@@ -16,13 +16,13 @@ RSpec.describe CypressOnRails::Middleware do
|
|
16
16
|
|
17
17
|
context '/__cypress__/command' do
|
18
18
|
before do
|
19
|
-
allow(command_executor).to receive(:
|
19
|
+
allow(command_executor).to receive(:perform).and_return({ id: 1, title: 'some result' })
|
20
20
|
allow(file).to receive(:exists?)
|
21
21
|
env['PATH_INFO'] = '/__cypress__/command'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'command file exists' do
|
25
|
-
allow(command_executor).to receive(:
|
25
|
+
allow(command_executor).to receive(:perform).and_return({ id: 1, title: 'some result' })
|
26
26
|
env['rack.input'] = rack_input(name: 'seed')
|
27
27
|
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
28
28
|
|
@@ -30,7 +30,7 @@ RSpec.describe CypressOnRails::Middleware do
|
|
30
30
|
expect(response).to eq([201,
|
31
31
|
{"Content-Type"=>"application/json"},
|
32
32
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
33
|
-
expect(command_executor).to have_received(:
|
33
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -42,13 +42,13 @@ RSpec.describe CypressOnRails::Middleware do
|
|
42
42
|
expect(response).to eq([201,
|
43
43
|
{"Content-Type"=>"application/json"},
|
44
44
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
45
|
-
expect(command_executor).to have_received(:
|
45
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', ['my_options'])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'command file does not exists' do
|
50
50
|
object = BasicObject.new
|
51
|
-
allow(command_executor).to receive(:
|
51
|
+
allow(command_executor).to receive(:perform).and_return(object)
|
52
52
|
env['rack.input'] = rack_input(name: 'seed')
|
53
53
|
allow(file).to receive(:exists?).with('spec/cypress/app_commands/seed.rb').and_return(true)
|
54
54
|
|
@@ -56,7 +56,7 @@ RSpec.describe CypressOnRails::Middleware do
|
|
56
56
|
expect(response).to eq([201,
|
57
57
|
{"Content-Type"=>"application/json"},
|
58
58
|
["{\"message\":\"Cannot convert to json\"}"]])
|
59
|
-
expect(command_executor).to have_received(:
|
59
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -68,7 +68,7 @@ RSpec.describe CypressOnRails::Middleware do
|
|
68
68
|
expect(response).to eq([201,
|
69
69
|
{"Content-Type"=>"application/json"},
|
70
70
|
["[{\"id\":1,\"title\":\"some result\"}]"]])
|
71
|
-
expect(command_executor).to have_received(:
|
71
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/seed.rb', nil)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -82,8 +82,8 @@ RSpec.describe CypressOnRails::Middleware do
|
|
82
82
|
expect(response).to eq([201,
|
83
83
|
{"Content-Type"=>"application/json"},
|
84
84
|
["[{\"id\":1,\"title\":\"some result\"},{\"id\":1,\"title\":\"some result\"}]"]])
|
85
|
-
expect(command_executor).to have_received(:
|
86
|
-
expect(command_executor).to have_received(:
|
85
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/load_user.rb', nil)
|
86
|
+
expect(command_executor).to have_received(:perform).with('spec/cypress/app_commands/load_sample.rb', {'all' => 'true'})
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -94,7 +94,7 @@ RSpec.describe CypressOnRails::Middleware do
|
|
94
94
|
|
95
95
|
aggregate_failures do
|
96
96
|
expect(response).to eq([404, {}, ['could not find command file: spec/cypress/app_commands/load_sample.rb']])
|
97
|
-
expect(command_executor).to_not have_received(:
|
97
|
+
expect(command_executor).to_not have_received(:perform)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cypress_on_rails/smart_factory_wrapper'
|
2
|
+
require 'factory_bot'
|
2
3
|
|
3
4
|
RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
4
5
|
FileSystemDummy = Struct.new(:file_hash) do
|
@@ -10,8 +11,9 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
10
11
|
let(:time_now) { Time.now }
|
11
12
|
let(:mtime_hash) { {'file1.rb' => time_now, 'file2.rb' => time_now } }
|
12
13
|
let(:files) { %w(file1.rb file2.rb) }
|
13
|
-
let(:factory_double)
|
14
|
-
|
14
|
+
let(:factory_double) do
|
15
|
+
class_double(FactoryBot, create: nil, create_list: nil, "definition_file_paths=": nil, reload: nil)
|
16
|
+
end
|
15
17
|
let(:kernel_double) { class_double(Kernel, load: true) }
|
16
18
|
let(:file_double) { FileSystemDummy.new(mtime_hash) }
|
17
19
|
let(:dir_double) { class_double(Dir) }
|
@@ -25,8 +27,7 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
25
27
|
factory: factory_double,
|
26
28
|
kernel: kernel_double,
|
27
29
|
file_system: file_double,
|
28
|
-
dir_system: dir_double
|
29
|
-
factory_cleaner: factory_cleaner)
|
30
|
+
dir_system: dir_double)
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'loads all the files on first create it' do
|
@@ -68,7 +69,7 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
68
69
|
|
69
70
|
it 'wont load the files if they have not changed' do
|
70
71
|
subject.create(:user)
|
71
|
-
subject.create_list(:user)
|
72
|
+
subject.create_list(:user, 2)
|
72
73
|
expect(kernel_double).to have_received(:load).with('file1.rb').once
|
73
74
|
expect(kernel_double).to have_received(:load).with('file2.rb').once
|
74
75
|
end
|
@@ -79,7 +80,7 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
79
80
|
expect(kernel_double).to have_received(:load).with('file2.rb').once
|
80
81
|
|
81
82
|
mtime_hash['file1.rb'] = Time.now
|
82
|
-
subject.create_list(:user)
|
83
|
+
subject.create_list(:user, 2)
|
83
84
|
expect(kernel_double).to have_received(:load).with('file1.rb').twice
|
84
85
|
expect(kernel_double).to have_received(:load).with('file2.rb').twice
|
85
86
|
end
|
@@ -91,24 +92,24 @@ RSpec.describe CypressOnRails::SmartFactoryWrapper do
|
|
91
92
|
expect(kernel_double).to have_received(:load).with('file2.rb').once
|
92
93
|
|
93
94
|
mtime_hash.delete('file1.rb')
|
94
|
-
subject.create_list(:user)
|
95
|
+
subject.create_list(:user, 2)
|
95
96
|
expect(kernel_double).to have_received(:load).with('file1.rb').once
|
96
97
|
expect(kernel_double).to have_received(:load).with('file2.rb').twice
|
97
98
|
end
|
98
99
|
|
99
|
-
it 'will reset factory if a has changed' do
|
100
|
+
it 'will reset factory if a file has changed' do
|
100
101
|
subject.create(:user)
|
101
|
-
expect(
|
102
|
+
expect(factory_double).to have_received(:reload)
|
102
103
|
|
103
104
|
mtime_hash['file1.rb'] = Time.now
|
104
|
-
subject.create_list(:user)
|
105
|
+
subject.create_list(:user, 2)
|
105
106
|
|
106
|
-
expect(
|
107
|
+
expect(factory_double).to have_received(:reload).twice
|
107
108
|
end
|
108
109
|
|
109
110
|
it 'will always reload the files enabled' do
|
110
111
|
subject.always_reload = true
|
111
|
-
subject.create_list(:user)
|
112
|
+
subject.create_list(:user, 2)
|
112
113
|
subject.create(:user)
|
113
114
|
expect(kernel_double).to have_received(:load).with('file1.rb').twice
|
114
115
|
expect(kernel_double).to have_received(:load).with('file2.rb').twice
|
@@ -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.1
|
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:
|
12
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.2'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: factory_bot
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
description: Integrates cypress with rails or rack applications
|
71
85
|
email:
|
72
86
|
- info@miceportal.de
|
@@ -75,6 +89,7 @@ executables: []
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
92
|
+
- ".github/FUNDING.yml"
|
78
93
|
- ".gitignore"
|
79
94
|
- ".rspec"
|
80
95
|
- ".travis.yml"
|
@@ -284,9 +299,14 @@ files:
|
|
284
299
|
- spec/integrations/rails_5_2/tmp/.keep
|
285
300
|
- spec/integrations/rails_5_2/vendor/.keep
|
286
301
|
- spec/spec_helper.rb
|
287
|
-
homepage: http://github.com/
|
302
|
+
homepage: http://github.com/shakacode/cypress-on-rails
|
288
303
|
licenses: []
|
289
|
-
metadata:
|
304
|
+
metadata:
|
305
|
+
bug_tracker_uri: https://github.com/shakacode/cypress-on-rails/issues
|
306
|
+
changelog_uri: https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md
|
307
|
+
documentation_uri: https://github.com/shakacode/cypress-on-rails/blob/master/README.md
|
308
|
+
homepage_uri: http://github.com/shakacode/cypress-on-rails
|
309
|
+
source_code_uri: http://github.com/shakacode/cypress-on-rails
|
290
310
|
post_install_message: The CypressDev constant is being deprecated and will be completely
|
291
311
|
removed and replaced with CypressOnRails.
|
292
312
|
rdoc_options: []
|
@@ -303,8 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
323
|
- !ruby/object:Gem::Version
|
304
324
|
version: '0'
|
305
325
|
requirements: []
|
306
|
-
|
307
|
-
rubygems_version: 2.6.14.4
|
326
|
+
rubygems_version: 3.2.11
|
308
327
|
signing_key:
|
309
328
|
specification_version: 4
|
310
329
|
summary: Integrates cypress with rails or rack applications
|