cypress-on-rails 1.10.1 → 1.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +63 -0
  3. data/.gitignore +5 -1
  4. data/CHANGELOG.md +65 -2
  5. data/README.md +261 -62
  6. data/cypress-on-rails.gemspec +1 -0
  7. data/docs/authentication.md +12 -10
  8. data/docs/factory_bot_associations.md +109 -0
  9. data/lib/cypress-on-rails.rb +2 -2
  10. data/lib/cypress_on_rails/command_executor.rb +9 -5
  11. data/lib/cypress_on_rails/configuration.rb +17 -2
  12. data/lib/cypress_on_rails/middleware.rb +15 -16
  13. data/lib/cypress_on_rails/middleware_config.rb +17 -0
  14. data/lib/cypress_on_rails/railtie.rb +5 -1
  15. data/lib/cypress_on_rails/smart_factory_wrapper.rb +49 -14
  16. data/lib/cypress_on_rails/vcr_middleware.rb +73 -0
  17. data/lib/cypress_on_rails/version.rb +1 -1
  18. data/lib/generators/cypress_on_rails/install_generator.rb +48 -30
  19. data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +3 -1
  20. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/advance_factory_bot_spec.js → e2e/rails_examples/advance_factory_bot.cy.js} +1 -1
  21. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/other_spec.js → e2e/rails_examples/other.cy.js} +1 -1
  22. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_factory_bot_spec.js → e2e/rails_examples/using_factory_bot.cy.js} +1 -1
  23. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_fixtures_spec.js → e2e/rails_examples/using_fixtures.cy.js} +1 -1
  24. data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_scenarios_spec.js → e2e/rails_examples/using_scenarios.cy.js} +1 -1
  25. data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js +24 -0
  26. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/{index.js → index.js.erb} +1 -0
  27. data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +9 -7
  28. data/lib/generators/cypress_on_rails/templates/spec/cypress.config.js +9 -0
  29. data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/clean.rb +8 -0
  30. data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/log_fail.rb +2 -0
  31. data/lib/generators/cypress_on_rails/templates/spec/{cypress/cypress_helper.rb → e2e/e2e_helper.rb.erb} +6 -1
  32. data/lib/generators/cypress_on_rails/templates/spec/playwright/e2e/rails_examples/using_scenarios.spec.js +12 -0
  33. data/lib/generators/cypress_on_rails/templates/spec/playwright/support/index.js.erb +21 -0
  34. data/lib/generators/cypress_on_rails/templates/spec/playwright/support/on-rails.js +37 -0
  35. data/lib/generators/cypress_on_rails/templates/spec/playwright.config.js +79 -0
  36. data/lib/generators/cypress_on_rails/update_generator.rb +14 -3
  37. data/plugin/.gitignore +1 -0
  38. data/plugin/cypress/plugins/index.js +4 -0
  39. data/plugin/package.json +31 -0
  40. data/plugin/support/index.js +37 -0
  41. data/spec/cypress_on_rails/command_executor_spec.rb +1 -1
  42. data/spec/cypress_on_rails/configuration_spec.rb +6 -3
  43. data/spec/cypress_on_rails/middleware_spec.rb +24 -22
  44. data/spec/cypress_on_rails/smart_factory_wrapper_spec.rb +33 -1
  45. data/spec/cypress_on_rails/vcr_middleware_spec.rb +119 -0
  46. data/specs_e2e/cypress.config.js +10 -0
  47. data/specs_e2e/playwright.config.js +79 -0
  48. data/{spec/integrations → specs_e2e}/rails_3_2/.gitignore +1 -1
  49. data/specs_e2e/rails_3_2/.ruby_version +1 -0
  50. data/{spec/integrations → specs_e2e}/rails_3_2/Gemfile +1 -1
  51. data/{spec/integrations → specs_e2e}/rails_3_2/test.sh +17 -11
  52. data/{spec/integrations → specs_e2e}/rails_4_2/.gitignore +3 -2
  53. data/{spec/integrations → specs_e2e}/rails_4_2/Gemfile +3 -1
  54. data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +10 -0
  55. data/{spec/integrations → specs_e2e}/rails_4_2/app/models/post.rb +3 -1
  56. data/specs_e2e/rails_4_2/app/views/using_vcr/index.html.erb +6 -0
  57. data/specs_e2e/rails_4_2/app/views/using_vcr/record_cats.html.erb +7 -0
  58. data/{spec/integrations → specs_e2e}/rails_4_2/config/routes.rb +5 -0
  59. data/specs_e2e/rails_4_2/package.json +10 -0
  60. data/specs_e2e/rails_4_2/test.sh +44 -0
  61. data/{spec/integrations → specs_e2e}/rails_5_2/.gitignore +1 -1
  62. data/{spec/integrations → specs_e2e}/rails_5_2/Gemfile +1 -1
  63. data/specs_e2e/rails_5_2/app/assets/javascripts/posts.js +2 -0
  64. data/specs_e2e/rails_5_2/app/assets/stylesheets/posts.css +4 -0
  65. data/specs_e2e/rails_5_2/test.sh +48 -0
  66. metadata +190 -177
  67. data/.travis.yml +0 -39
  68. data/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json +0 -5
  69. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js +0 -272
  70. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/aliasing.spec.js +0 -42
  71. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/assertions.spec.js +0 -63
  72. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/connectors.spec.js +0 -55
  73. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cookies.spec.js +0 -78
  74. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js +0 -211
  75. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/files.spec.js +0 -86
  76. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/local_storage.spec.js +0 -52
  77. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/location.spec.js +0 -32
  78. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/misc.spec.js +0 -68
  79. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/navigation.spec.js +0 -54
  80. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/network_requests.spec.js +0 -108
  81. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/querying.spec.js +0 -65
  82. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/spies_stubs_clocks.spec.js +0 -62
  83. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/traversal.spec.js +0 -121
  84. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/utilities.spec.js +0 -89
  85. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/viewport.spec.js +0 -59
  86. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/waiting.spec.js +0 -34
  87. data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/window.spec.js +0 -22
  88. data/lib/generators/cypress_on_rails/templates/spec/cypress.json +0 -4
  89. data/spec/integrations/cypress.json +0 -5
  90. data/spec/integrations/rails_4_2/test.sh +0 -38
  91. data/spec/integrations/rails_5_2/test.sh +0 -41
  92. data/spec/integrations/rails_5_2/tmp/.keep +0 -0
  93. data/spec/integrations/rails_5_2/vendor/.keep +0 -0
  94. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/activerecord_fixtures.rb +0 -0
  95. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/eval.rb +0 -0
  96. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/factory_bot.rb +0 -0
  97. /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/scenarios/basic.rb +0 -0
  98. /data/spec/cypress_on_rails/command_executor/{cypress_helper.rb → e2e_helper.rb} +0 -0
  99. /data/{spec/integrations → specs_e2e}/rails_3_2/README.rdoc +0 -0
  100. /data/{spec/integrations → specs_e2e}/rails_3_2/Rakefile +0 -0
  101. /data/{spec/integrations → specs_e2e}/rails_3_2/app/assets/stylesheets/application.css +0 -0
  102. /data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/application_controller.rb +0 -0
  103. /data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/welcome_controller.rb +0 -0
  104. /data/{spec/integrations → specs_e2e}/rails_3_2/app/helpers/application_helper.rb +0 -0
  105. /data/{spec/integrations → specs_e2e}/rails_3_2/app/models/post.rb +0 -0
  106. /data/{spec/integrations → specs_e2e}/rails_3_2/app/views/layouts/application.html.erb +0 -0
  107. /data/{spec/integrations → specs_e2e}/rails_3_2/app/views/welcome/index.html.erb +0 -0
  108. /data/{spec/integrations → specs_e2e}/rails_3_2/bin/rails +0 -0
  109. /data/{spec/integrations → specs_e2e}/rails_3_2/config/application.rb +0 -0
  110. /data/{spec/integrations → specs_e2e}/rails_3_2/config/boot.rb +0 -0
  111. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environment.rb +0 -0
  112. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/development.rb +0 -0
  113. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/production.rb +0 -0
  114. /data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/test.rb +0 -0
  115. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/backtrace_silencers.rb +0 -0
  116. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/inflections.rb +0 -0
  117. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/mime_types.rb +0 -0
  118. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/secret_token.rb +0 -0
  119. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/session_store.rb +0 -0
  120. /data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/wrap_parameters.rb +0 -0
  121. /data/{spec/integrations → specs_e2e}/rails_3_2/config/locales/en.yml +0 -0
  122. /data/{spec/integrations → specs_e2e}/rails_3_2/config/routes.rb +0 -0
  123. /data/{spec/integrations → specs_e2e}/rails_3_2/config.ru +0 -0
  124. /data/{spec/integrations → specs_e2e}/rails_3_2/log/.keep +0 -0
  125. /data/{spec/integrations → specs_e2e}/rails_3_2/public/404.html +0 -0
  126. /data/{spec/integrations → specs_e2e}/rails_3_2/public/422.html +0 -0
  127. /data/{spec/integrations → specs_e2e}/rails_3_2/public/500.html +0 -0
  128. /data/{spec/integrations → specs_e2e}/rails_3_2/public/favicon.ico +0 -0
  129. /data/{spec/integrations → specs_e2e}/rails_3_2/public/robots.txt +0 -0
  130. /data/{spec/integrations → specs_e2e}/rails_3_2/tmp/.keep +0 -0
  131. /data/{spec/integrations → specs_e2e}/rails_3_2/vendor/.gitkeep +0 -0
  132. /data/{spec/integrations → specs_e2e}/rails_4_2/README.rdoc +0 -0
  133. /data/{spec/integrations → specs_e2e}/rails_4_2/Rakefile +0 -0
  134. /data/{spec/integrations/rails_5_2/app/assets/javascripts/posts.js → specs_e2e/rails_4_2/app/assets/javascripts/using_vcr.js} +0 -0
  135. /data/{spec/integrations/rails_5_2/app/assets/stylesheets/posts.css → specs_e2e/rails_4_2/app/assets/stylesheets/using_vcr.css} +0 -0
  136. /data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/application_controller.rb +0 -0
  137. /data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/welcome_controller.rb +0 -0
  138. /data/{spec/integrations → specs_e2e}/rails_4_2/app/views/layouts/application.html.erb +0 -0
  139. /data/{spec/integrations → specs_e2e}/rails_4_2/app/views/welcome/index.html.erb +0 -0
  140. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/bundle +0 -0
  141. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/rails +0 -0
  142. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/rake +0 -0
  143. /data/{spec/integrations → specs_e2e}/rails_4_2/bin/setup +0 -0
  144. /data/{spec/integrations → specs_e2e}/rails_4_2/config/application.rb +0 -0
  145. /data/{spec/integrations → specs_e2e}/rails_4_2/config/boot.rb +0 -0
  146. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environment.rb +0 -0
  147. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/development.rb +0 -0
  148. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/production.rb +0 -0
  149. /data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/test.rb +0 -0
  150. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/backtrace_silencers.rb +0 -0
  151. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/cookies_serializer.rb +0 -0
  152. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/filter_parameter_logging.rb +0 -0
  153. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/inflections.rb +0 -0
  154. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/mime_types.rb +0 -0
  155. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/session_store.rb +0 -0
  156. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/to_time_preserves_timezone.rb +0 -0
  157. /data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/wrap_parameters.rb +0 -0
  158. /data/{spec/integrations → specs_e2e}/rails_4_2/config/locales/en.yml +0 -0
  159. /data/{spec/integrations → specs_e2e}/rails_4_2/config/secrets.yml +0 -0
  160. /data/{spec/integrations → specs_e2e}/rails_4_2/config.ru +0 -0
  161. /data/{spec/integrations → specs_e2e}/rails_4_2/public/404.html +0 -0
  162. /data/{spec/integrations → specs_e2e}/rails_4_2/public/422.html +0 -0
  163. /data/{spec/integrations → specs_e2e}/rails_4_2/public/500.html +0 -0
  164. /data/{spec/integrations → specs_e2e}/rails_4_2/public/favicon.ico +0 -0
  165. /data/{spec/integrations → specs_e2e}/rails_4_2/public/robots.txt +0 -0
  166. /data/{spec/integrations/rails_4_2/log → specs_e2e/rails_4_2/spec}/.keep +0 -0
  167. /data/{spec/integrations/rails_4_2/spec → specs_e2e/rails_4_2/vendor}/.keep +0 -0
  168. /data/{spec/integrations → specs_e2e}/rails_5_2/README.md +0 -0
  169. /data/{spec/integrations → specs_e2e}/rails_5_2/Rakefile +0 -0
  170. /data/{spec/integrations → specs_e2e}/rails_5_2/app/assets/stylesheets/scaffold.css +0 -0
  171. /data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/application_controller.rb +0 -0
  172. /data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/posts_controller.rb +0 -0
  173. /data/{spec/integrations → specs_e2e}/rails_5_2/app/helpers/posts_helper.rb +0 -0
  174. /data/{spec/integrations → specs_e2e}/rails_5_2/app/jobs/application_job.rb +0 -0
  175. /data/{spec/integrations → specs_e2e}/rails_5_2/app/models/application_record.rb +0 -0
  176. /data/{spec/integrations → specs_e2e}/rails_5_2/app/models/post.rb +0 -0
  177. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/layouts/application.html.erb +0 -0
  178. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/_form.html.erb +0 -0
  179. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/edit.html.erb +0 -0
  180. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/index.html.erb +0 -0
  181. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/new.html.erb +0 -0
  182. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/show.html.erb +0 -0
  183. /data/{spec/integrations → specs_e2e}/rails_5_2/app/views/welcome/index.html.erb +0 -0
  184. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/bundle +0 -0
  185. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/rails +0 -0
  186. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/rake +0 -0
  187. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/setup +0 -0
  188. /data/{spec/integrations → specs_e2e}/rails_5_2/bin/update +0 -0
  189. /data/{spec/integrations → specs_e2e}/rails_5_2/config/application.rb +0 -0
  190. /data/{spec/integrations → specs_e2e}/rails_5_2/config/boot.rb +0 -0
  191. /data/{spec/integrations → specs_e2e}/rails_5_2/config/credentials.yml.enc +0 -0
  192. /data/{spec/integrations → specs_e2e}/rails_5_2/config/database.yml +0 -0
  193. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environment.rb +0 -0
  194. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/development.rb +0 -0
  195. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/production.rb +0 -0
  196. /data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/test.rb +0 -0
  197. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/application_controller_renderer.rb +0 -0
  198. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/backtrace_silencers.rb +0 -0
  199. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/content_security_policy.rb +0 -0
  200. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/cookies_serializer.rb +0 -0
  201. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/filter_parameter_logging.rb +0 -0
  202. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/inflections.rb +0 -0
  203. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/mime_types.rb +0 -0
  204. /data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/wrap_parameters.rb +0 -0
  205. /data/{spec/integrations → specs_e2e}/rails_5_2/config/locales/en.yml +0 -0
  206. /data/{spec/integrations → specs_e2e}/rails_5_2/config/master.key +0 -0
  207. /data/{spec/integrations → specs_e2e}/rails_5_2/config/routes.rb +0 -0
  208. /data/{spec/integrations → specs_e2e}/rails_5_2/config.ru +0 -0
  209. /data/{spec/integrations → specs_e2e}/rails_5_2/db/migrate/20180621085832_create_posts.rb +0 -0
  210. /data/{spec/integrations → specs_e2e}/rails_5_2/public/404.html +0 -0
  211. /data/{spec/integrations → specs_e2e}/rails_5_2/public/422.html +0 -0
  212. /data/{spec/integrations → specs_e2e}/rails_5_2/public/500.html +0 -0
  213. /data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon-precomposed.png +0 -0
  214. /data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon.png +0 -0
  215. /data/{spec/integrations → specs_e2e}/rails_5_2/public/favicon.ico +0 -0
  216. /data/{spec/integrations → specs_e2e}/rails_5_2/public/robots.txt +0 -0
  217. /data/{spec/integrations → specs_e2e}/rails_5_2/test/controllers/posts_controller_test.rb +0 -0
  218. /data/{spec/integrations → specs_e2e}/rails_5_2/test/cypress_fixtures/posts.yml +0 -0
  219. /data/{spec/integrations → specs_e2e}/rails_5_2/test/fixtures/posts.yml +0 -0
  220. /data/{spec/integrations → specs_e2e}/rails_5_2/test/models/post_test.rb +0 -0
  221. /data/{spec/integrations/rails_4_2 → specs_e2e/rails_5_2}/vendor/.keep +0 -0
  222. /data/{spec/integrations/rails_5_2/log/.keep → tmp/pids/.gitkeep} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19c6280b01cef6fe5088f9a3d1098acf69a116f6118e219992f961f7af7f1a6d
4
- data.tar.gz: 8408f84cf6d400a87136243c34c49ed228ccde27f14e824aa88d053bf435ad78
3
+ metadata.gz: 9cb0dd8412c42d59d5c687cd911a1a41819296f0fd8c8796e58365620be94897
4
+ data.tar.gz: 0baeb4e448a0f7e069f0774caadb0829f6ecd710f38ef06942674c2114cd9244
5
5
  SHA512:
6
- metadata.gz: d72faf8adc3ed46442e0bcd91b5420d3dda942192ba014f4ce435284448e06a44de95f72c5d5a007357902eab0d64a7f4965da839c966243997a56ebcecab3e9
7
- data.tar.gz: 25e8fad0237b6e3f0a891a4d202273257210e42a0056db6026a70a3cbc0c6851a3763e7c2e70016ab76ec3efc7586d786741e271cd0855d52741e6387d6064ed
6
+ metadata.gz: 2836bd208f1cb49b4ad0e25c2bd20cfe6b7fcaaac97fa739e7dc10516fb291b0a220a6bab3678f05329c104bf0f596fb4ec8e9fb2f2d28fade4d59299e1c7169
7
+ data.tar.gz: 783e8a833f7dd2e386b7fa0b245c1ce9c039835a1600e511148f0cb76a584819f5a1a9af88d1681bbd86a8dfefa4a43a389ea871dce18a30224791f0b6e7cd2f
@@ -0,0 +1,63 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ rails_3_2:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.3
19
+ bundler-cache: true
20
+ - name: Run tests
21
+ run: bundle exec rake
22
+ - run: gem uninstall -v '>= 2' -ax bundler || true
23
+ - run: gem install bundler -v '< 2'
24
+ - name: Run interaction tests
25
+ run: ./specs_e2e/rails_3_2/test.sh
26
+ env:
27
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
28
+
29
+ rails_4_2:
30
+ runs-on: ubuntu-latest
31
+
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - name: Set up Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: 2.5
38
+ bundler-cache: true
39
+ - name: Run tests
40
+ run: bundle exec rake
41
+ - run: gem uninstall -v '>= 2' -ax bundler || true
42
+ - run: gem install bundler -v '< 2'
43
+ - name: Run interaction tests
44
+ run: ./specs_e2e/rails_4_2/test.sh
45
+ env:
46
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
47
+
48
+ rails_5_2:
49
+ runs-on: ubuntu-latest
50
+
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+ - name: Set up Ruby
54
+ uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: 2.6
57
+ bundler-cache: true
58
+ - name: Run tests
59
+ run: bundle exec rake
60
+ - name: Run interaction tests
61
+ run: ./specs_e2e/rails_5_2/test.sh
62
+ env:
63
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
data/.gitignore CHANGED
@@ -5,4 +5,8 @@ spec/examples.txt
5
5
  .idea
6
6
  spec/test.log
7
7
  pkg/*.gem
8
- vendor/bundle
8
+ vendor/bundle
9
+ .vscode
10
+ node_modules
11
+ package-lock.json
12
+ yarn.lock
data/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
- ## [1.10.0]
2
- [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.1...v1.10.0
1
+ ## [1.15.1]
2
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.15.0...v1.15.1
3
+
4
+ ### Fixed
5
+ * fix cypress_folder deprecation warning by internal code [PR 136](https://github.com/shakacode/cypress-on-rails/pull/136)
6
+
7
+ ## [1.15.0]
8
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.14.0...v1.15.0
9
+
10
+ ### Changed
11
+ * Add support for any e2e testing framewrok starting with Playwright [PR 131](https://github.com/shakacode/cypress-on-rails/pull/131) by [KhaledEmaraDev]
12
+
13
+ ## [1.14.0]
14
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.1...v1.14.0
15
+
16
+ ### Changed
17
+ * Add support for proxy routes through `api_prefix` [PR 130](https://github.com/shakacode/cypress-on-rails/pull/130) by [RomainEndelin]
18
+
19
+ ### Fixed
20
+ * Properly copies the cypress_helper file when running the update generator [PR 117](https://github.com/shakacode/cypress-on-rails/pull/117) by [alvincrespo]
21
+
22
+ ### Tasks
23
+ * pass cypress record key to github action [PR 110](https://github.com/shakacode/cypress-on-rails/pull/110)
24
+
25
+ ## [1.13.1]
26
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.0...v1.13.1
27
+
28
+ ### Fixed
29
+ * use_vcr_middleware disabled by default [PR 109](https://github.com/shakacode/cypress-on-rails/pull/109)
30
+
31
+ ## [1.13.0]
32
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.1...v1.13.0
33
+
34
+ ### Changed
35
+ * Add support for matching npm package and VCR
36
+ * generate for cypress 10 [PR 108](https://github.com/shakacode/cypress-on-rails/pull/108)
37
+
38
+ ## [1.12.1]
39
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.0...v1.12.1
40
+
41
+ ### Tasks
42
+ * Documenting how to setup Factory Associations [PR 100](https://github.com/shakacode/cypress-on-rails/pull/100)
43
+
44
+ ### Fixed
45
+ * keep track of factory manual reloads to prevent auto_reload from reloading again [PR 98](https://github.com/shakacode/cypress-on-rails/pull/98)
46
+
47
+ ## [1.12.0]
48
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0
49
+
50
+ ### Changed
51
+ * only reload factories on clean instead of every factory create request [PR 95](https://github.com/shakacode/cypress-on-rails/pull/95)
52
+ * alternative command added for get tail of logs [PR 89](https://github.com/shakacode/cypress-on-rails/pull/89) by [ccrockett]
53
+
54
+ ### Tasks
55
+ * switch from travis to github actions [PR 96]
56
+
57
+ ## [1.11.0]
58
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.10.1...v1.11.0
59
+
60
+ ### Changed
61
+ * improve app command logging on cypress
62
+ * Allow build and build_list commands to be executed against factory bot [PR 87](https://github.com/shakacode/cypress-on-rails/pull/87) by [Alexander-Blair]
63
+
64
+ ## [1.10.1]
65
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.1...v1.10.1
3
66
 
4
67
  ### Changed
5
68
  * improve error message received from failed command
data/README.md CHANGED
@@ -1,24 +1,34 @@
1
1
  # CypressOnRails
2
2
 
3
- [![Build Status](https://travis-ci.com/shakacode/cypress-on-rails.svg?branch=master)](https://travis-ci.org/shakacode/cypress-on-rails) [![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
3
+ ![Build Status](https://github.com/shakacode/cypress-on-rails/actions/workflows/ruby.yml/badge.svg)
4
+ [![cypress-on-rails](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/2b6cjr/master&style=plastic&logo=cypress)](https://dashboard.cypress.io/projects/2b6cjr/runs)
5
+ [![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
4
6
 
5
7
  ----
6
8
 
7
- This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React front-ends, often with Ruby on Rails or Gatsby. The best way to see what we do is to see the details of [our recent work](https://www.shakacode.com/recent-work). Feel free to engage in discussions around this gem at our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
9
+ This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React (with TS or ReScript) front-ends, often with Ruby on Rails or Gatsby. See [our recent work](https://www.shakacode.com/recent-work) and [client engagement model](https://www.shakacode.com/blog/client-engagement-model/). Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
10
+
11
+ Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
12
+
13
+ Need help with cypress-on-rails? Contact [ShakaCode](mailto:justin@shakacode.com).
8
14
 
9
15
  ----
10
16
 
11
17
  # Totally new to Cypress?
12
18
  Suggest you first learn the basics of Cypress before attempting to integrate with Ruby on Rails
13
19
 
14
- * [Good start Here](https://docs.cypress.io/examples/examples/tutorials.html#Best-Practices)
20
+ * [Good start Here](https://docs.cypress.io/examples/tutorials.html#Best-Practices)
21
+
22
+ # Totally new to Playwright?
23
+ Suggest you first learn the basics of Playwright before attempting to integrate with Ruby on Rails
24
+
25
+ * [Good start Here](https://playwright.dev/docs/writing-tests)
15
26
 
16
27
  ## Overview
17
28
 
18
- Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and ruby rack applications
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)
29
+ Gem for using [cypress.io](http://github.com/cypress-io/) or [playwright.dev](https://playwright.dev/) in Rails and Ruby Rack applications 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)
20
30
 
21
- It allows to run code in the application context when executing cypress tests.
31
+ It allows you to run code in the application context when executing cypress or playwright tests.
22
32
  Do things like:
23
33
  * use database_cleaner before each test
24
34
  * seed the database with default data for each test
@@ -37,7 +47,7 @@ Has examples of setting up state with:
37
47
 
38
48
  ## Installation
39
49
 
40
- Add this to your Gemfile:
50
+ Add this to your `Gemfile`:
41
51
 
42
52
  ```ruby
43
53
  group :test, :development do
@@ -48,11 +58,21 @@ end
48
58
  Generate the boilerplate code using:
49
59
 
50
60
  ```shell
61
+ # by default installs only cypress
51
62
  bin/rails g cypress_on_rails:install
52
63
 
53
64
  # if you have/want a different cypress folder (default is cypress)
54
65
  bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
55
66
 
67
+ # to install both cypress and playwright
68
+ bin/rails g cypress_on_rails:install --install_cypress --install_playwright --playwright_folder=playwright
69
+
70
+ # to change where the Ruby files reside (default is e2e)
71
+ bin/rails g cypress_on_rails:install --install_folder=test/e2e
72
+
73
+ # if you target the Rails server with a path prefix to your URL
74
+ bin/rails g cypress_on_rails:install --api_prefix=/api
75
+
56
76
  # if you want to install cypress with npm
57
77
  bin/rails g cypress_on_rails:install --install_cypress_with=npm
58
78
 
@@ -64,27 +84,27 @@ bin/rails g cypress_on_rails:update
64
84
  ```
65
85
 
66
86
  The generator modifies/adds the following files/directory in your application:
67
- * `config/environments/test.rb`
68
- * `config/initializers/cypress_on_rails` used to configure CypressDev
69
- * `spec/cypress/integrations/` contains your cypress tests
70
- * `spec/cypress/support/on-rails.js` contains CypressDev support code
71
- * `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
72
- * `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
87
+ * `config/initializers/cypress_on_rails.rb` used to configure Cypress on Rails
88
+ * `spec/cypress/e2e/` contains your cypress tests
89
+ * `spec/playwright/e2e/` contains your playwright tests
90
+ * `spec/cypress/support/on-rails.js` contains Cypress on Rails support code
91
+ * `spec/playwright/support/on-rails.js` contains Playwright on Rails support code
92
+ * `spec/e2e/app_commands/scenarios/` contains your Cypress on Rails scenario definitions
93
+ * `spec/e2e/cypress_helper.rb` contains helper code for Cypress on Rails app commands
73
94
 
74
- if you are not using database_cleaner look at `spec/cypress/app_commands/clean.rb`.
75
- if you are not using factory_bot look at `spec/cypress/app_commands/factory_bot.rb`.
95
+ If you are not using `database_cleaner` look at `spec/e2e/app_commands/clean.rb`.
96
+ If you are not using `factory_bot` look at `spec/e2e/app_commands/factory_bot.rb`.
76
97
 
77
- Now you can create scenarios and commands that are plain ruby files that get loaded through middleware, the ruby sky is your limit.
98
+ Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit.
78
99
 
79
100
  ### Update your database.yml
80
101
 
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
102
+ When running `cypress test` or `playwright test` on your local computer it's recommended to start your server in development mode so that changes you
103
+ make are picked up without having to restart the server.
104
+ It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database
84
105
  otherwise cypress will keep clearing your development database.
85
106
 
86
- for example:
87
-
107
+ For example:
88
108
  ```yaml
89
109
  development:
90
110
  <<: *default
@@ -107,11 +127,15 @@ Getting started on your local environment
107
127
  CYPRESS=1 bin/rails server -p 5017
108
128
 
109
129
  # in separate window start cypress
110
- yarn cypress open
130
+ yarn cypress open
111
131
  # or for npm
112
- node_modules/.bin/cypress open
132
+ node_modules/.bin/cypress open
113
133
  # or if you changed the cypress folder to spec/cypress
114
134
  yarn cypress open --project ./spec
135
+ # or for playwright
136
+ yarn playwright test --ui
137
+ # or using npm
138
+ npx playwright test --ui
115
139
  ```
116
140
 
117
141
  How to run cypress on CI
@@ -122,28 +146,17 @@ How to run cypress on CI
122
146
 
123
147
  yarn run cypress run
124
148
  # or for npm
125
- node_modules/.bin/cypress run
149
+ npx cypress run
126
150
  ```
127
151
 
128
152
  ### Example of using factory bot
129
153
 
130
154
  You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
131
155
 
132
- ```ruby
133
- # spec/cypress/app_commands/factory_bot.rb
134
- require 'cypress_on_rails/smart_factory_wrapper'
135
-
136
- CypressOnRails::SmartFactoryWrapper.configure(
137
- always_reload: !Rails.configuration.cache_classes,
138
- factory: FactoryBot,
139
- files: Dir['./spec/factories/**/*.rb']
140
- )
141
- ```
142
-
143
156
  ```js
144
- // spec/cypress/integrations/simple_spec.js
145
- describe('My First Test', function() {
146
- it('visit root', function() {
157
+ // spec/cypress/e2e/simple.cy.js
158
+ describe('My First Test', () => {
159
+ it('visit root', () => {
147
160
  // This calls to the backend to prepare the application state
148
161
  cy.appFactories([
149
162
  ['create_list', 'post', 10],
@@ -154,7 +167,7 @@ describe('My First Test', function() {
154
167
  // Visit the application under test
155
168
  cy.visit('/')
156
169
 
157
- cy.contains("Hello World")
170
+ cy.contains('Hello World')
158
171
 
159
172
  // Accessing result
160
173
  cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
@@ -163,10 +176,47 @@ describe('My First Test', function() {
163
176
  })
164
177
  })
165
178
  ```
179
+ You can check the [association docs](docs/factory_bot_associations.md) on more ways to setup association with the correct data.
180
+
181
+ In some cases, using static Cypress fixtures may not provide sufficient flexibility when mocking HTTP response bodies. It's possible to use `FactoryBot.build` to generate Ruby hashes that can then be used as mock JSON responses:
182
+ ```ruby
183
+ FactoryBot.define do
184
+ factory :some_web_response, class: Hash do
185
+ initialize_with { attributes.deep_stringify_keys }
186
+
187
+ id { 123 }
188
+ name { 'Mr Blobby' }
189
+ occupation { 'Evil pink clown' }
190
+ end
191
+ end
192
+
193
+ FactoryBot.build(:some_web_response => { 'id' => 123, 'name' => 'Mr Blobby', 'occupation' => 'Evil pink clown' })
194
+ ```
195
+
196
+ This can then be combined with Cypress mocks:
197
+ ```js
198
+ describe('My First Test', () => {
199
+ it('visit root', () => {
200
+ // This calls to the backend to generate the mocked response
201
+ cy.appFactories([
202
+ ['build', 'some_web_response', { name: 'Baby Blobby' }]
203
+ ]).then(([responseBody]) => {
204
+ cy.intercept('http://some-external-url.com/endpoint', {
205
+ body: responseBody
206
+ });
207
+
208
+ // Visit the application under test
209
+ cy.visit('/')
210
+ })
211
+
212
+ cy.contains('Hello World')
213
+ })
214
+ })
215
+ ```
166
216
 
167
- ### Example of loading rails test fixtures
217
+ ### Example of loading Rails test fixtures
168
218
  ```ruby
169
- # spec/cypress/app_commands/activerecord_fixtures.rb
219
+ # spec/e2e/app_commands/activerecord_fixtures.rb
170
220
  require "active_record/fixtures"
171
221
 
172
222
  fixtures_dir = ActiveRecord::Tasks::DatabaseTasks.fixtures_path
@@ -178,16 +228,16 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
178
228
  ```
179
229
 
180
230
  ```js
181
- // spec/cypress/integrations/simple_spec.js
182
- describe('My First Test', function() {
183
- it('visit root', function() {
231
+ // spec/cypress/e2e/simple.cy.js
232
+ describe('My First Test', () => {
233
+ it('visit root', () => {
184
234
  // This calls to the backend to prepare the application state
185
235
  cy.appFixtures()
186
236
 
187
237
  // Visit the application under test
188
238
  cy.visit('/')
189
239
 
190
- cy.contains("Hello World")
240
+ cy.contains('Hello World')
191
241
  })
192
242
  })
193
243
  ```
@@ -196,7 +246,7 @@ describe('My First Test', function() {
196
246
 
197
247
  Scenarios are named `before` blocks that you can reference in your test.
198
248
 
199
- You define a scenario in the `spec/cypress/app_commands/scenarios` directory:
249
+ You define a scenario in the `spec/e2e/app_commands/scenarios` directory:
200
250
  ```ruby
201
251
  # spec/cypress/app_commands/scenarios/basic.rb
202
252
  Profile.create name: "Cypress Hill"
@@ -207,34 +257,34 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
207
257
 
208
258
  Then reference the scenario in your test:
209
259
  ```js
210
- // spec/cypress/integrations/scenario_example_spec.js
211
- describe('My First Test', function() {
212
- it('visit root', function() {
260
+ // spec/cypress/e2e/scenario_example.cy.js
261
+ describe('My First Test', () => {
262
+ it('visit root', () => {
213
263
  // This calls to the backend to prepare the application state
214
264
  cy.appScenario('basic')
215
265
 
216
266
  cy.visit('/profiles')
217
267
 
218
- cy.contains("Cypress Hill")
268
+ cy.contains('Cypress Hill')
219
269
  })
220
270
  })
221
271
  ```
222
272
 
223
273
  ### Example of using app commands
224
274
 
225
- create a ruby file in `spec/cypress/app_commands` directory:
275
+ Create a Ruby file in the `spec/e2e/app_commands` directory:
226
276
  ```ruby
227
- # spec/cypress/app_commands/load_seed.rb
277
+ # spec/e2e/app_commands/load_seed.rb
228
278
  load "#{Rails.root}/db/seeds.rb"
229
279
  ```
230
280
 
231
281
  Then reference the command in your test with `cy.app('load_seed')`:
232
282
  ```js
233
- // spec/cypress/integrations/simple_spec.js
234
- describe('My First Test', function() {
283
+ // spec/cypress/e2e/simple.cy.js
284
+ describe('My First Test', () => {
235
285
  beforeEach(() => { cy.app('load_seed') })
236
286
 
237
- it('visit root', function() {
287
+ it('visit root', () => {
238
288
  cy.visit('/')
239
289
 
240
290
  cy.contains("Seeds")
@@ -242,6 +292,109 @@ describe('My First Test', function() {
242
292
  })
243
293
  ```
244
294
 
295
+ ### Example of using scenario with Playwright
296
+
297
+ Scenarios are named `before` blocks that you can reference in your test.
298
+
299
+ You define a scenario in the `spec/e2e/app_commands/scenarios` directory:
300
+ ```ruby
301
+ # spec/e2e/app_commands/scenarios/basic.rb
302
+ Profile.create name: "Cypress Hill"
303
+
304
+ # or if you have factory_bot enabled in your cypress_helper
305
+ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
306
+ ```
307
+
308
+ Then reference the scenario in your test:
309
+ ```js
310
+ // spec/playwright/e2e/scenario_example.spec.js
311
+ import { test, expect } from "@playwright/test";
312
+ import { app, appScenario } from '../../support/on-rails';
313
+
314
+ test.describe("Rails using scenarios examples", () => {
315
+ test.beforeEach(async ({ page }) => {
316
+ await app('clean');
317
+ });
318
+
319
+ test("setup basic scenario", async ({ page }) => {
320
+ await appScenario('basic');
321
+ await page.goto("/");
322
+ });
323
+ });
324
+ ```
325
+
326
+ ## Experimental Features (matching npm package)
327
+
328
+ Please test and give feedback.
329
+
330
+ Add the npm package:
331
+
332
+ ```
333
+ yarn add cypress-on-rails --dev
334
+ ```
335
+
336
+ ### for VCR
337
+
338
+ This only works when you start the Rails server with a single worker and single thread
339
+
340
+ #### setup
341
+
342
+ Add your VCR configuration to your `cypress_helper.rb`
343
+
344
+ ```ruby
345
+ require 'vcr'
346
+ VCR.configure do |config|
347
+ config.hook_into :webmock
348
+ end
349
+ ```
350
+
351
+ Add to your `cypress/support/index.js`:
352
+
353
+ ```js
354
+ import 'cypress-on-rails/support/index'
355
+ ```
356
+
357
+ Add to your `cypress/app_commands/clean.rb`:
358
+
359
+ ```ruby
360
+ VCR.eject_cassette # make sure we no cassettes inserted before the next test starts
361
+ VCR.turn_off!
362
+ WebMock.disable! if defined?(WebMock)
363
+ ```
364
+
365
+ Add to your `config/cypress_on_rails.rb`:
366
+
367
+ ```ruby
368
+ c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
369
+ ```
370
+
371
+ #### usage
372
+
373
+ You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette
374
+
375
+
376
+ ```js
377
+ describe('My First Test', () => {
378
+ beforeEach(() => { cy.app('load_seed') })
379
+
380
+ it('visit root', () => {
381
+ cy.app('clean') // have a look at e2e/app_commands/clean.rb
382
+
383
+ cy.vcr_insert_cassette('cats', { record: "new_episodes" })
384
+ cy.visit('/using_vcr/index')
385
+
386
+ cy.get('a').contains('Cats').click()
387
+ cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
388
+
389
+ cy.vcr_eject_cassette()
390
+
391
+ cy.vcr_insert_cassette('cats')
392
+ cy.visit('/using_vcr/record_cats')
393
+ cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
394
+ })
395
+ })
396
+ ```
397
+
245
398
  ## Usage with other rack applications
246
399
 
247
400
  Add CypressOnRails to your config.ru
@@ -259,30 +412,30 @@ use CypressOnRails::Middleware
259
412
  run MyApp
260
413
  ```
261
414
 
262
- add the following file to cypress
415
+ add the following file to Cypress
263
416
 
264
417
  ```js
265
418
  // test/cypress/support/on-rails.js
266
- // CypressOnRails: dont remove these command
267
- Cypress.Commands.add('appCommands', function (body) {
419
+ // CypressOnRails: don't remove these commands
420
+ Cypress.Commands.add('appCommands', (body) => {
268
421
  cy.request({
269
422
  method: 'POST',
270
- url: "/__cypress__/command",
423
+ url: '/__cypress__/command',
271
424
  body: JSON.stringify(body),
272
425
  log: true,
273
426
  failOnStatusCode: true
274
427
  })
275
428
  });
276
429
 
277
- Cypress.Commands.add('app', function (name, command_options) {
430
+ Cypress.Commands.add('app', (name, command_options) => {
278
431
  cy.appCommands({name: name, options: command_options})
279
432
  });
280
433
 
281
- Cypress.Commands.add('appScenario', function (name) {
434
+ Cypress.Commands.add('appScenario', (name) => {
282
435
  cy.app('scenarios/' + name)
283
436
  });
284
437
 
285
- Cypress.Commands.add('appFactories', function (options) {
438
+ Cypress.Commands.add('appFactories', (options) => {
286
439
  cy.app('factory_bot', options)
287
440
  });
288
441
  // CypressOnRails: end
@@ -293,6 +446,17 @@ beforeEach(() => {
293
446
  });
294
447
  ```
295
448
 
449
+ ## API Prefix
450
+
451
+ If your Rails server is exposed under a proxy, typically https://my-local.dev/api, you can use the `api_prefix` option.
452
+ In `config/initializers/cypress_on_rails.rb`, add this line:
453
+ ```ruby
454
+ CypressOnRails.configure do |c|
455
+ # ...
456
+ c.api_prefix = '/api'
457
+ end
458
+ ```
459
+
296
460
  ## Contributing
297
461
 
298
462
  1. Fork it ( https://github.com/shakacode/cypress-on-rails/fork )
@@ -300,3 +464,38 @@ beforeEach(() => {
300
464
  3. Commit your changes (`git commit -am 'Add some feature'`)
301
465
  4. Push to the branch (`git push origin my-new-feature`)
302
466
  5. Create a new Pull Request
467
+
468
+ ## Supporters
469
+
470
+ <a href="https://www.jetbrains.com">
471
+ <img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
472
+ </a>
473
+ <a href="https://scoutapp.com">
474
+ <picture>
475
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881147-0d077438-3978-40da-ace9-4f650d2efe2e.png">
476
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png">
477
+ <img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
478
+ </picture>
479
+ </a>
480
+ <br />
481
+ <a href="https://www.browserstack.com">
482
+ <picture>
483
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881122-407dcc29-df78-4b20-a9ad-f597b56f6cdb.png">
484
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png">
485
+ <img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
486
+ </picture>
487
+ </a>
488
+ <a href="https://railsautoscale.com">
489
+ <img src="https://user-images.githubusercontent.com/4244251/184881144-95c2c25c-9879-4069-864d-4e67d6ed39d2.png" alt="Rails Autoscale" height="55px">
490
+ </a>
491
+ <a href="https://www.honeybadger.io">
492
+ <img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
493
+ </a>
494
+ <a href="https://reviewable.io">
495
+ <img src="https://user-images.githubusercontent.com/20628911/230848305-c94510a4-82d7-468f-bf9f-eeb81d3f2ce0.png" alt="Reviewable" height="55px">
496
+ </a>
497
+
498
+ <br />
499
+ <br />
500
+
501
+ The following companies support our open source projects, and ShakaCode uses their products!
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'rspec'
21
21
  s.add_development_dependency 'railties', '>= 3.2'
22
22
  s.add_development_dependency 'factory_bot'
23
+ s.add_development_dependency 'vcr'
23
24
  s.metadata = {
24
25
  "bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
25
26
  "changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md",