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
@@ -0,0 +1,119 @@
1
+ require 'cypress_on_rails/vcr_middleware'
2
+ require 'vcr'
3
+ require 'active_support/core_ext/hash' unless Hash.new.respond_to?(:symbolize_keys)
4
+
5
+ module CypressOnRails
6
+ RSpec.describe VCRMiddleware do
7
+ let(:app) { ->(env) { [200, {}, ["app did #{env['PATH_INFO']}"]] } }
8
+ let(:vcr) { class_double(VCR, turn_on!: true, turn_off!: true, insert_cassette: true, eject_cassette: true) }
9
+ subject { described_class.new(app, vcr) }
10
+
11
+ let(:env) { {} }
12
+
13
+ let(:response) { subject.call(env) }
14
+
15
+ def rack_input(json_value)
16
+ StringIO.new(JSON.generate(json_value))
17
+ end
18
+
19
+ describe '/__e2e__/vcr/insert' do
20
+ before do
21
+ env['PATH_INFO'] = '/__e2e__/vcr/insert'
22
+ end
23
+
24
+ it do
25
+ env['rack.input'] = rack_input(['cas1'])
26
+
27
+ aggregate_failures do
28
+ expect(response).to eq([201,
29
+ {"Content-Type"=>"application/json"},
30
+ ["{\"message\":\"OK\"}"]])
31
+ expect(vcr).to have_received(:turn_on!)
32
+ expect(vcr).to have_received(:insert_cassette).with('cas1', {})
33
+ end
34
+ end
35
+
36
+ it 'works with record' do
37
+ env['rack.input'] = rack_input(['cas1', { "record" => "new_episodes" }])
38
+
39
+ aggregate_failures do
40
+ expect(response).to eq([201,
41
+ {"Content-Type"=>"application/json"},
42
+ ["{\"message\":\"OK\"}"]])
43
+ expect(vcr).to have_received(:insert_cassette).with('cas1', record: :new_episodes)
44
+ end
45
+ end
46
+
47
+ it 'works with match_requests_on' do
48
+ env['rack.input'] = rack_input(['cas1', { "match_requests_on" => ["method", "uri"] }])
49
+
50
+ aggregate_failures do
51
+ expect(response).to eq([201,
52
+ {"Content-Type"=>"application/json"},
53
+ ["{\"message\":\"OK\"}"]])
54
+ expect(vcr).to have_received(:insert_cassette).with('cas1', match_requests_on: [:method, :uri])
55
+ end
56
+ end
57
+
58
+ it 'works with serialize_with' do
59
+ env['rack.input'] = rack_input(['cas1', { "serialize_with" => "yaml" }])
60
+
61
+ aggregate_failures do
62
+ expect(response).to eq([201,
63
+ {"Content-Type"=>"application/json"},
64
+ ["{\"message\":\"OK\"}"]])
65
+ expect(vcr).to have_received(:insert_cassette).with('cas1', serialize_with: :yaml)
66
+ end
67
+ end
68
+
69
+ it 'works with persist_with' do
70
+ env['rack.input'] = rack_input(['cas1', { "persist_with" => "file_system" }])
71
+
72
+ aggregate_failures do
73
+ expect(response).to eq([201,
74
+ {"Content-Type"=>"application/json"},
75
+ ["{\"message\":\"OK\"}"]])
76
+ expect(vcr).to have_received(:insert_cassette).with('cas1', persist_with: :file_system)
77
+ end
78
+ end
79
+ end
80
+
81
+ describe '/__e2e__/vcr/eject' do
82
+ before do
83
+ env['PATH_INFO'] = '/__e2e__/vcr/eject'
84
+ end
85
+
86
+ it do
87
+ aggregate_failures do
88
+ expect(response).to eq([201,
89
+ {"Content-Type"=>"application/json"},
90
+ ["{\"message\":\"OK\"}"]])
91
+ expect(vcr).to have_received(:turn_off!)
92
+ expect(vcr).to have_received(:eject_cassette)
93
+ end
94
+ end
95
+ end
96
+
97
+ describe '"Other paths"' do
98
+ it 'calls vcr turn off the first time' do
99
+ env['PATH_INFO'] = '/test'
100
+
101
+ expect(response).to eq([200, {}, ["app did /test"]])
102
+ expect(vcr).to have_received(:turn_off!)
103
+ end
104
+
105
+ it 'runs app' do
106
+ aggregate_failures do
107
+ %w(/ /__e2e__/login command /e2e_command /).each do |path|
108
+ env['PATH_INFO'] = path
109
+
110
+ response = subject.call(env)
111
+
112
+ expect(response).to eq([200, {}, ["app did #{path}"]])
113
+ expect(vcr).to have_received(:turn_off!)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,10 @@
1
+ const { defineConfig } = require('cypress')
2
+
3
+ module.exports = defineConfig({
4
+ projectId: "2b6cjr",
5
+ e2e: {
6
+ baseUrl: "http://localhost:5017",
7
+ defaultCommandTimeout: 10000,
8
+ supportFile: "cypress/support/index.js"
9
+ }
10
+ })
@@ -0,0 +1,79 @@
1
+ // @ts-check
2
+ const { defineConfig, devices } = require('@playwright/test');
3
+
4
+ /**
5
+ * Read environment variables from file.
6
+ * https://github.com/motdotla/dotenv
7
+ */
8
+ // require('dotenv').config();
9
+
10
+ /**
11
+ * @see https://playwright.dev/docs/test-configuration
12
+ */
13
+ module.exports = defineConfig({
14
+ testDir: './playwright/e2e',
15
+ /* Run tests in files in parallel */
16
+ fullyParallel: true,
17
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
18
+ forbidOnly: !!process.env.CI,
19
+ /* Retry on CI only */
20
+ retries: process.env.CI ? 2 : 0,
21
+ /* Opt out of parallel tests on CI. */
22
+ workers: process.env.CI ? 1 : undefined,
23
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
24
+ reporter: 'html',
25
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
26
+ use: {
27
+ /* Base URL to use in actions like `await page.goto('/')`. */
28
+ baseURL: 'http://127.0.0.1:5017',
29
+
30
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31
+ trace: 'on-first-retry',
32
+ },
33
+
34
+ /* Configure projects for major browsers */
35
+ projects: [
36
+ {
37
+ name: 'chromium',
38
+ use: { ...devices['Desktop Chrome'] },
39
+ },
40
+
41
+ {
42
+ name: 'firefox',
43
+ use: { ...devices['Desktop Firefox'] },
44
+ },
45
+
46
+ {
47
+ name: 'webkit',
48
+ use: { ...devices['Desktop Safari'] },
49
+ },
50
+
51
+ /* Test against mobile viewports. */
52
+ // {
53
+ // name: 'Mobile Chrome',
54
+ // use: { ...devices['Pixel 5'] },
55
+ // },
56
+ // {
57
+ // name: 'Mobile Safari',
58
+ // use: { ...devices['iPhone 12'] },
59
+ // },
60
+
61
+ /* Test against branded browsers. */
62
+ // {
63
+ // name: 'Microsoft Edge',
64
+ // use: { ...devices['Desktop Edge'], channel: 'msedge' },
65
+ // },
66
+ // {
67
+ // name: 'Google Chrome',
68
+ // use: { ..devices['Desktop Chrome'], channel: 'chrome' },
69
+ // },
70
+ ],
71
+
72
+ /* Run your local dev server before starting the tests */
73
+ // webServer: {
74
+ // command: 'npm run start',
75
+ // url: 'http://127.0.0.1:3000',
76
+ // reuseExistingServer: !process.env.CI,
77
+ // },
78
+ });
79
+
@@ -1,6 +1,6 @@
1
1
  .bundle
2
2
  node_modules
3
- cypress.json
3
+ cypress.config.js
4
4
  package-lock.json
5
5
  cypress/
6
6
  config/initializers/cypress_on_rails.rb
@@ -0,0 +1 @@
1
+ 2.3.8
@@ -3,5 +3,5 @@ source 'https://rubygems.org'
3
3
  gem 'rails', '~> 3.2.22'
4
4
 
5
5
  group :development, :test do
6
- gem 'cypress-on-rails', path: '../../../'
6
+ gem 'cypress-on-rails', path: '../../'
7
7
  end
@@ -4,9 +4,9 @@ set -eo pipefail
4
4
  echo '--- testing rails 3.2'
5
5
 
6
6
  echo '-- setting environment'
7
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8
- RAILS_ENV=test
9
- BUNDLE_GEMFILE="$DIR/Gemfile"
7
+ export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8
+ export RAILS_ENV=test
9
+ export BUNDLE_GEMFILE="$DIR/Gemfile"
10
10
  cd $DIR
11
11
 
12
12
  echo '-- bundle install'
@@ -14,8 +14,9 @@ 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 --install_cypress_with=npm
18
- rm -vf cypress/integration/rails_examples/advance_factory_bot_spec.js
17
+ bundle exec ./bin/rails g cypress_on_rails:install --install_cypress --install_playwright --install_with=npm
18
+ rm -vf cypress/e2e/rails_examples/advance_factory_bot.cy.js
19
+ rm -vf cypress/e2e/rails_examples/using_vcr.cy.js
19
20
 
20
21
  echo '-- start rails server'
21
22
  # make sure the server is not running
@@ -25,13 +26,18 @@ bundle exec ./bin/rails server -p 5017 -e test &
25
26
  sleep 2 # give rails a chance to start up correctly
26
27
 
27
28
  echo '-- cypress run'
28
- cp -fv ../cypress.json .
29
- if [ -z $CYPRESS_RECORD_KEY ]
30
- then
31
- node_modules/.bin/cypress run
32
- else
29
+ cp -fv ../cypress.config.js .
30
+ # if [ -z $CYPRESS_RECORD_KEY ]
31
+ # then
32
+ # node_modules/.bin/cypress run
33
+ # else
33
34
  node_modules/.bin/cypress run --record
34
- fi
35
+ # fi
36
+
37
+ echo '-- playwright run'
38
+ cp -fv ../playwright.config.js .
39
+ npx playwright install-deps
40
+ npx playwright test playwright/e2e/
35
41
 
36
42
  echo '-- stop rails server'
37
43
  kill -9 `cat tmp/pids/server.pid`
@@ -1,10 +1,11 @@
1
1
  .bundle
2
2
  spec/node_modules
3
- spec/cypress.json
3
+ spec/cypress.config.js
4
4
  spec/package.json
5
5
  spec/yarn.lock
6
6
  spec/cypress
7
7
  config/initializers/cypress_on_rails.rb
8
8
  vendor/bundle
9
9
  tmp/pids
10
- tmp/cache
10
+ tmp/cache
11
+ log/*.*
@@ -5,5 +5,7 @@ gem 'rails', '~> 4.2.10'
5
5
  gem 'sprockets', '~> 3.7.2'
6
6
 
7
7
  group :development, :test do
8
- gem 'cypress-on-rails', path: '../../../'
8
+ gem 'vcr'
9
+ gem 'webmock'
10
+ gem 'cypress-on-rails', path: '../../'
9
11
  end
@@ -0,0 +1,10 @@
1
+ class UsingVcrController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def record_cats
6
+ uri = URI('https://cat-fact.herokuapp.com/facts')
7
+ res = Net::HTTP.get_response(uri)
8
+ @cat_facts = JSON.parse(res.body)
9
+ end
10
+ end
@@ -7,7 +7,9 @@ class Post < OpenStruct
7
7
  @all ||= []
8
8
  post = new(attributes)
9
9
  @all << post
10
- attributes['all'] = @all.index(post)
10
+ post.id = @all.index(post)
11
+ attributes['id'] = @all.index(post)
12
+ attributes
11
13
  end
12
14
 
13
15
  def self.all
@@ -0,0 +1,6 @@
1
+ <h1>Using VCR</h1>
2
+ <pre>
3
+ <%= JSON.pretty_generate VCR.configuration.as_json['default_cassette_options'] %>
4
+ </pre>
5
+
6
+ <%= link_to 'Record Cats', { action: :record_cats } %>
@@ -0,0 +1,7 @@
1
+ <h1>Record from Cats API</h1>
2
+
3
+ <ul>
4
+ <% @cat_facts.each do |fact| %>
5
+ <li><%= fact['text'] %></li>
6
+ <% end %>
7
+ <ul>
@@ -1,10 +1,15 @@
1
1
  Rails.application.routes.draw do
2
+ get 'using_vcr/index'
3
+
2
4
  # The priority is based upon order of creation: first created -> highest priority.
3
5
  # See how all your routes lay out with "rake routes".
4
6
 
5
7
  # You can have the root of your site routed with "root"
6
8
  root 'welcome#index'
7
9
 
10
+ get 'using_vcr/:action', to: 'using_vcr#:action'
11
+
12
+
8
13
  # Example of regular route:
9
14
  # get 'products/:id' => 'catalog#view'
10
15
 
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "rails_4_2",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "license": "MIT",
6
+ "devDependencies": {
7
+ "cypress": "^10.0.2",
8
+ "cypress-on-rails": "file:../../plugin"
9
+ }
10
+ }
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ set -eo pipefail
3
+
4
+ echo '--- testing rails 4.2'
5
+
6
+ echo '-- setting environment'
7
+ export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8
+ export RAILS_ENV=test
9
+ export BUNDLE_GEMFILE="$DIR/Gemfile"
10
+ cd $DIR
11
+
12
+ echo '-- bundle install'
13
+ gem install bundler -v "~> 1.0" --conservative
14
+ bundle --version
15
+ bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle
16
+
17
+ echo '-- cypress and playwright install'
18
+ bundle exec ./bin/rails g cypress_on_rails:install --install_folder=spec/e2e --cypress_folder=spec/cypress --playwright_folder=spec/playwright --install_cypress --install_playwright --experimental --install_with=npm --skip
19
+ rm -vf spec/cypress/e2e/rails_examples/advance_factory_bot.cy.js
20
+
21
+ echo '-- start rails server'
22
+ # make sure the server is not running
23
+ (kill -9 `cat tmp/pids/server.pid` || true )
24
+
25
+ bundle exec ./bin/rails server -p 5017 -e test &
26
+ sleep 5 # give rails a chance to start up correctly
27
+
28
+ echo '-- cypress run'
29
+ cp -fv ../cypress.config.js spec/
30
+ # if [ -z $CYPRESS_RECORD_KEY ]
31
+ # then
32
+ # npx cypress run -P ./spec
33
+ # else
34
+ npx cypress run -P ./spec --record
35
+ # fi
36
+
37
+ echo '-- playwright run'
38
+ cp -fv ../playwright.config.js spec/
39
+ cd spec
40
+ npx playwright install-deps
41
+ npx playwright test spec/playwright/e2e/
42
+
43
+ echo '-- stop rails server'
44
+ kill -9 `cat tmp/pids/server.pid` || true
@@ -1,6 +1,6 @@
1
1
  .bundle
2
2
  test/node_modules
3
- test/cypress.json
3
+ test/cypress.config.js
4
4
  test/package.json
5
5
  test/yarn.lock
6
6
  test/cypress/
@@ -11,5 +11,5 @@ gem 'bootsnap', '>= 1.1.0', require: false
11
11
 
12
12
  group :development, :test do
13
13
  gem 'database_cleaner'
14
- gem 'cypress-on-rails', path: '../../../'
14
+ gem 'cypress-on-rails', path: '../../'
15
15
  end
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ set -eo pipefail
3
+
4
+ echo '--- testing rails 5.2'
5
+
6
+ echo '-- setting environment'
7
+ export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8
+ export RAILS_ENV=test
9
+ export BUNDLE_GEMFILE="$DIR/Gemfile"
10
+ cd $DIR
11
+
12
+ echo '-- bundle install'
13
+ bundle --version
14
+ bundle config set --local path 'vendor/bundle'
15
+ bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2
16
+
17
+ echo '-- migration'
18
+ bundle exec ./bin/rails db:drop || true
19
+ bundle exec ./bin/rails db:create db:migrate
20
+
21
+ echo '-- cypress and playwright install'
22
+ bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test/e2e --cypress_folder=test/cypress --playwright_folder=test/playwright --install_cypress --install_playwright --install_with=npm --skip
23
+ rm -vf test/cypress/e2e/rails_examples/using_vcr.cy.js
24
+
25
+ echo '-- start rails server'
26
+ # make sure the server is not running
27
+ (kill -9 `cat tmp/pids/server.pid` || true )
28
+
29
+ bundle exec ./bin/rails server -p 5017 -e test &
30
+ sleep 2 # give rails a chance to start up correctly
31
+
32
+ echo '-- cypress run'
33
+ cp -fv ../cypress.config.js test/
34
+ cd test
35
+ # if [ -z $CYPRESS_RECORD_KEY ]
36
+ # then
37
+ # npx cypress run
38
+ # else
39
+ npx cypress run --record
40
+ # fi
41
+
42
+ echo '-- playwright run'
43
+ cp -fv ../../playwright.config.js .
44
+ npx playwright install-deps
45
+ npx playwright test test/playwright/e2e/
46
+
47
+ echo '-- stop rails server'
48
+ kill -9 `cat ../tmp/pids/server.pid` || true