cypress-on-rails 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 49942b0febcf64950936386fdbcbec0601534923
4
- data.tar.gz: dba819774cec41583fb545fe2517a9baceaf029a
2
+ SHA256:
3
+ metadata.gz: b729d2f84bc4c0ae47bf5604c2f51a8c9c5b793f8256a3e698e127cbb5b54974
4
+ data.tar.gz: 957791607d573fe7a5d1193df5fc59b7c99f349bf023a71827c2de0dc77e2ffe
5
5
  SHA512:
6
- metadata.gz: dd5ab5135eeec0405b53356e5205956a5ea2f7230341663ac206b76292eb895eef297a96e28345f94dd78ffc8cbda2c54ac0b408dec097dc18edfb760da2ef53
7
- data.tar.gz: ca4fb0a7f72ad6341fcb3c14aa22b6142ed95ffa3a77a5e6e229eeb3fc0d6e9290bb67edec65edb99ecae093044b4a795dc1611c6c5b193e764dcc76a1072e71
6
+ metadata.gz: 889c0983aeb92cbbbb7cc51ffdb33033bfc33d169bf123483f63b417b522cbdd3e62f1855b4ea36b47d866d6dd2c26fba0e63a939e6e1573640604ee0833cab3
7
+ data.tar.gz: 1cfabe2cd7c2a39b622aff2c140babd7818050f7289973a4f89d08803906540d78113f4826d1eb07b1f6ebbedc0f334bab3688e2576d375d60a800d9c7197d20
@@ -0,0 +1 @@
1
+ github: [shakacode]
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ spec/examples.txt
5
5
  .idea
6
6
  spec/test.log
7
7
  pkg/*.gem
8
+ vendor/bundle
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3
4
+ - 2.4
4
5
  - 2.5
5
6
  - 2.6
7
+ # - 2.7
6
8
 
7
9
  #addons:
8
10
  # artifacts:
@@ -24,9 +26,14 @@ before_install:
24
26
  - sudo apt-get -qq update
25
27
  - sudo apt-get install -y build-essential patch ruby-dev zlib1g-dev liblzma-dev libxml2-dev
26
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
27
32
 
28
33
  script:
29
34
  - bundle exec rake
35
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
36
+ - gem install bundler -v '< 2'
30
37
  - ./spec/integrations/rails_5_2/test.sh
31
38
  - ./spec/integrations/rails_4_2/test.sh
32
39
  - ./spec/integrations/rails_3_2/test.sh
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
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
+
10
+ ## [1.8.1]
11
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.8.0...v1.8.1
12
+
13
+ ### Fixed
14
+ * remove "--silent" option when adding cypress [PR 76](https://github.com/shakacode/cypress-on-rails/pull/76)
15
+ * 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)
16
+
17
+ ## [1.8.0]
18
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.7.0...v1.8.0
19
+
20
+ ### Changed
21
+ * Use `FactoryBo#reload` to reset factory bot
22
+
23
+ ## [1.7.0]
24
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.6.0...v1.7.0
25
+
26
+ ### Changed
27
+ * Improve eval() in command executor [PR 46](https://github.com/shakacode/cypress-on-rails/pull/46) by [Systho](https://github.com/Systho)
28
+
29
+ ### Fixed
30
+ * Add middleware after load_config_initializers [PR 62](https://github.com/shakacode/cypress-on-rails/pull/62) by [duytd](https://github.com/duytd)
31
+
32
+ ## [1.6.0]
33
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.1...v1.6.0
34
+
35
+ ### Changed
36
+ * Change default port to 5017 [PR 49](https://github.com/shakacode/cypress-on-rails/pull/49) by [vfonic](https://github/vfonic)
37
+
38
+ ### Fixed
39
+ * fix file location warning message in clean.rb [PR 54](https://github.com/shakacode/cypress-on-rails/pull/54) by [ootoovak](https://github.com/ootoovak)
40
+
1
41
  ## [1.5.1]
2
42
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.0...v1.5.1
3
43
 
@@ -32,7 +72,7 @@
32
72
  * Update Travis CI badge in README [PR 31](https://github.com/shakacode/cypress-on-rails/pull/31)
33
73
  * Fix CI by Installing cypress dependencies on Travis CI [PR 31](https://github.com/shakacode/cypress-on-rails/pull/31)
34
74
 
35
- ## [1.4.0]
75
+ ## [1.4.0]
36
76
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.3.0...v1.4.0
37
77
 
38
78
  * Accept an options argument for scenarios. [PR 18](https://github.com/shakacode/cypress-on-rails/pull/18) by [ericraio](https://github.com/ericraio).
@@ -98,6 +138,14 @@
98
138
  ## 0.1.2 (2017-10-31)
99
139
  * First release.
100
140
 
141
+ [1.8.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.7.0...v1.8.0
142
+ [1.7.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.6.0...v1.7.0
143
+ [1.6.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.1...v1.6.0
144
+ [1.5.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.5.0...v1.5.1
145
+ [1.5.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.2...v1.5.0
146
+ [1.4.2]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.1...v1.4.2
147
+ [1.4.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.4.0...v1.4.1
148
+ [1.4.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.3.0...v1.4.0
101
149
  [1.3.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.1...v1.3.0
102
150
  [1.2.1]: https://github.com/shakacode/cypress-on-rails/compare/v1.2.0...v1.2.1
103
151
  [1.2.0]: https://github.com/shakacode/cypress-on-rails/compare/v1.1.1...v1.2.0
data/README.md CHANGED
@@ -8,7 +8,14 @@ This project is sponsored by the software consulting firm [ShakaCode](https://ww
8
8
 
9
9
  ----
10
10
 
11
- Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and ruby rack applications
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
+
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
 
14
21
  It allows to run code in the application context when executing cypress tests.
@@ -24,44 +31,68 @@ Has examples of setting up state with:
24
31
  * scenarios
25
32
  * custom commands
26
33
 
27
- This gem is based off https://github.com/konvenit/cypress-on-rails
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
- Video of getting started with this gem https://grant-ps.blog/2018/08/10/getting-started-with-cypress-io-and-ruby-on-rails/
30
-
31
- ## Getting started
38
+ ## Installation
32
39
 
33
40
  Add this to your Gemfile:
34
- ```
41
+
42
+ ```ruby
35
43
  group :test, :development do
36
44
  gem 'cypress-on-rails', '~> 1.0'
37
45
  end
38
46
  ```
39
47
 
40
48
  Generate the boilerplate code using:
41
- ```
49
+
50
+ ```shell
42
51
  bin/rails g cypress_on_rails:install
43
52
 
44
- # if you have/want a different cypress folder (default is spec/cypress)
45
- bin/rails g cypress_on_rails:install --cypress_folder=test/cypress
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
  ```
53
65
 
54
- The generator adds the following files/directory to your application:
66
+ The generator modifies/adds the following files/directory in your application:
67
+ * `config/environments/test.rb`
55
68
  * `config/initializers/cypress_on_rails` used to configure CypressDev
56
69
  * `spec/cypress/integrations/` contains your cypress tests
57
70
  * `spec/cypress/support/on-rails.js` contains CypressDev support code
58
71
  * `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
59
72
  * `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
60
73
 
61
- if you are not using database_cleaner look at `spec/cypress/app_commands/clean_db.rb`.
74
+ if you are not using database_cleaner look at `spec/cypress/app_commands/clean.rb`.
62
75
  if you are not using factory_bot look at `spec/cypress/app_commands/factory_bot.rb`.
63
76
 
64
- Now you can create scenarios and commands that are plan ruby files that get loaded through middleware, the ruby sky is your limit.
77
+ Now you can create scenarios and commands that are plain ruby files that get loaded through middleware, the ruby sky is your limit.
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
+ ```
65
96
 
66
97
  ### WARNING
67
98
  *WARNING!!:* cypress-on-rails can execute arbitrary ruby code
@@ -69,18 +100,33 @@ Please use with extra caution if starting your local server on 0.0.0.0 or runnin
69
100
 
70
101
  ## Usage
71
102
 
72
- Start the rails server in test mode and start cypress
103
+ Getting started on your local environment
73
104
 
74
- ```
105
+ ```shell
75
106
  # start rails
76
- RAILS_ENV=test bin/rake db:create db:schema:load
77
- bin/rails server -e test -p 5002
107
+ CYPRESS=1 bin/rails server -p 5017
78
108
 
79
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
80
114
  yarn cypress open --project ./spec
81
115
  ```
82
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
+
83
128
  ### Example of using factory bot
129
+
84
130
  You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
85
131
 
86
132
  ```ruby
@@ -88,10 +134,10 @@ You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) direct
88
134
  require 'cypress_on_rails/smart_factory_wrapper'
89
135
 
90
136
  CypressOnRails::SmartFactoryWrapper.configure(
91
- always_reload: !Rails.configuration.cache_classes,
92
- factory: FactoryBot,
93
- files: Dir['./spec/factories/**/*.rb']
94
- )
137
+ always_reload: !Rails.configuration.cache_classes,
138
+ factory: FactoryBot,
139
+ files: Dir['./spec/factories/**/*.rb']
140
+ )
95
141
  ```
96
142
 
97
143
  ```js
@@ -101,16 +147,17 @@ describe('My First Test', function() {
101
147
  // This calls to the backend to prepare the application state
102
148
  cy.appFactories([
103
149
  ['create_list', 'post', 10],
104
- ['create', 'post', {title: 'Hello World'} ]
150
+ ['create', 'post', {title: 'Hello World'} ],
151
+ ['create', 'post', 'with_comments', {title: 'Factory_bot Traits here'} ] // use traits
105
152
  ])
106
153
 
107
154
  // Visit the application under test
108
155
  cy.visit('/')
109
156
 
110
157
  cy.contains("Hello World")
111
-
158
+
112
159
  // Accessing result
113
- cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
160
+ cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
114
161
  cy.visit(`/invoices/${records[0].id}`);
115
162
  });
116
163
  })
@@ -155,7 +202,7 @@ You define a scenario in the `spec/cypress/app_commands/scenarios` directory:
155
202
  Profile.create name: "Cypress Hill"
156
203
 
157
204
  # or if you have factory_bot enabled in your cypress_helper
158
- CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
205
+ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
159
206
  ```
160
207
 
161
208
  Then reference the scenario in your test:
@@ -177,8 +224,8 @@ describe('My First Test', function() {
177
224
 
178
225
  create a ruby file in `spec/cypress/app_commands` directory:
179
226
  ```ruby
180
- # spec/cypress/app_commands/load_seed.rb
181
- load "#{Rails.root}/db/seeds.rb"
227
+ # spec/cypress/app_commands/load_seed.rb
228
+ load "#{Rails.root}/db/seeds.rb"
182
229
  ```
183
230
 
184
231
  Then reference the command in your test with `cy.app('load_seed')`:
@@ -186,7 +233,7 @@ Then reference the command in your test with `cy.app('load_seed')`:
186
233
  // spec/cypress/integrations/simple_spec.js
187
234
  describe('My First Test', function() {
188
235
  beforeEach(() => { cy.app('load_seed') })
189
-
236
+
190
237
  it('visit root', function() {
191
238
  cy.visit('/')
192
239
 
@@ -209,7 +256,7 @@ CypressOnRails.configure do |c|
209
256
  end
210
257
  use CypressOnRails::Middleware
211
258
 
212
- run MyApp
259
+ run MyApp
213
260
  ```
214
261
 
215
262
  add the following file to cypress
@@ -248,7 +295,7 @@ beforeEach(() => {
248
295
 
249
296
  ## Contributing
250
297
 
251
- 1. Fork it ( https://github.com/[my-github-username]/cypress-on-rails/fork )
298
+ 1. Fork it ( https://github.com/shakacode/cypress-on-rails/fork )
252
299
  2. Create your feature branch (`git checkout -b my-new-feature`)
253
300
  3. Commit your changes (`git commit -am 'Add some feature'`)
254
301
  4. Push to the branch (`git push origin my-new-feature`)
@@ -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/grantspeelman/cypress-on-rails"
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
@@ -6,7 +6,7 @@ module CypressOnRails
6
6
  def self.load(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"))
@@ -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
@@ -12,5 +12,9 @@ module CypressOnRails
12
12
  create(type,*params)
13
13
  end
14
14
  end
15
+
16
+ # to be API compatible with factorybot
17
+ def self.definition_file_paths=(*); end
18
+ def self.reload; end
15
19
  end
16
20
  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
- factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File,
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
- @factory_cleaner.clean(factory)
76
+ factory.reload
87
77
  files.each do |file|
88
78
  logger.debug "-- Loading: #{file}"
89
79
  @kernel.load(file)
@@ -1,3 +1,3 @@
1
1
  module CypressOnRails
2
- VERSION = '1.5.1'
2
+ VERSION = '1.9.0'.freeze
3
3
  end
@@ -1,8 +1,9 @@
1
1
  module CypressOnRails
2
2
  class InstallGenerator < Rails::Generators::Base
3
- class_option :cypress_folder, type: :string, default: 'spec/cypress'
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: true
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.install_cypress_with == 'yarn'
15
- command = "yarn --cwd=#{install_dir} add cypress --dev --silent"
16
- elsif options.install_cypress_with == 'npm'
17
- command = "cd #{install_dir}; npm install cypress --save-dev --silent"
18
- end
19
- if command
20
- say command
21
- fail 'failed to install cypress' unless system(command)
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.test?
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,4 +1,4 @@
1
1
  {
2
- "baseUrl": "http://localhost:5002",
2
+ "baseUrl": "http://localhost:5017",
3
3
  "defaultCommandTimeout": 10000
4
4
  }
@@ -3,7 +3,7 @@ if defined?(DatabaseCleaner)
3
3
  DatabaseCleaner.strategy = :truncation
4
4
  DatabaseCleaner.clean
5
5
  else
6
- logger.warn "add database_cleaner or update clean_db"
6
+ logger.warn "add database_cleaner or update cypress/app_commands/clean.rb"
7
7
  Post.delete_all if defined?(Post)
8
8
  end
9
9
 
@@ -1,9 +1,14 @@
1
1
  # This is loaded once before the first command is executed
2
2
 
3
3
  begin
4
- require 'database_cleaner'
4
+ require 'database_cleaner-active_record'
5
5
  rescue LoadError => e
6
- puts e.message
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
@@ -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
- whitelist: 'session_id',
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
- whitelist (xhr) {
88
- // handle custom logic for whitelisting
87
+ preserve (xhr) {
88
+ // handle custom logic for preserving
89
89
  },
90
90
  })
91
91
  })
@@ -112,7 +112,7 @@ context('Cypress.config()', () => {
112
112
  let myConfig = Cypress.config()
113
113
 
114
114
  expect(myConfig).to.have.property('animationDistanceThreshold', 5)
115
- expect(myConfig).to.have.property('baseUrl', 'http://localhost:5002')
115
+ expect(myConfig).to.have.property('baseUrl', 'http://localhost:5017')
116
116
  expect(myConfig).to.have.property('defaultCommandTimeout', 10000)
117
117
  expect(myConfig).to.have.property('requestTimeout', 5000)
118
118
  expect(myConfig).to.have.property('responseTimeout', 30000)
@@ -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) { double('FactoryBot', create: true, create_list: true) }
14
- let(:factory_cleaner) { class_double(CypressOnRails::SmartFactoryWrapper::FactoryCleaner, clean: true) }
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(factory_cleaner).to have_received(:clean).with(factory_double)
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(factory_cleaner).to have_received(:clean).with(factory_double).twice
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "baseUrl": "http://localhost:5002",
2
+ "baseUrl": "http://localhost:5017",
3
3
  "defaultCommandTimeout": 10000,
4
4
  "projectId": "qvzwep"
5
5
  }
@@ -14,14 +14,14 @@ 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 --cypress_folder=cypress --install_cypress_with=npm --no-install-cypress-examples
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'
21
21
  # make sure the server is not running
22
22
  (kill -9 `cat tmp/pids/server.pid` || true )
23
23
 
24
- bundle exec ./bin/rails server -p 5002 -e test &
24
+ bundle exec ./bin/rails server -p 5017 -e test &
25
25
  sleep 2 # give rails a chance to start up correctly
26
26
 
27
27
  echo '-- cypress run'
@@ -1,7 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
- gem 'rails', '4.2.10'
4
+ gem 'rails', '~> 4.2.10'
5
+ gem 'sprockets', '~> 3.7.2'
5
6
 
6
7
  group :development, :test do
7
8
  gem 'cypress-on-rails', path: '../../../'
@@ -14,14 +14,14 @@ 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 --no-install-cypress-examples
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'
21
21
  # make sure the server is not running
22
22
  (kill -9 `cat tmp/pids/server.pid` || true )
23
23
 
24
- bundle exec ./bin/rails server -p 5002 -e test &
24
+ bundle exec ./bin/rails server -p 5017 -e test &
25
25
  sleep 2 # give rails a chance to start up correctly
26
26
 
27
27
  echo '-- cypress run'
@@ -3,6 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
5
  gem 'rails', '~> 5.2.0'
6
+ gem 'sprockets', '~> 3.7.2'
6
7
  gem 'sqlite3', '~> 1.3.6'
7
8
 
8
9
  # Reduces boot times through caching; required in config/boot.rb
@@ -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:migrate
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
@@ -23,7 +24,7 @@ echo '-- start rails server'
23
24
  # make sure the server is not running
24
25
  (kill -9 `cat tmp/pids/server.pid` || true )
25
26
 
26
- bundle exec ./bin/rails server -p 5002 -e test &
27
+ bundle exec ./bin/rails server -p 5017 -e test &
27
28
  sleep 2 # give rails a chance to start up correctly
28
29
 
29
30
  echo '-- cypress run'
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.5.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: 2020-01-14 00:00:00.000000000 Z
12
+ date: 2021-03-01 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/grantspeelman/cypress-on-rails
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
- rubyforge_project:
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