integration-tests-rails 0.2.6 → 1.0.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
2
  SHA256:
3
- metadata.gz: 92a09da9d48590c9072d36f161fd9f3fb4852ab94c0973d9fd956f784db15ca8
4
- data.tar.gz: 7153e044c5eed5872652e79f3fa5ca9aec0ed81186ea9501aaa7f6ca300a1002
3
+ metadata.gz: 4cbfc69eebf1fd54a4b04781e9e269852aee8ef0aaeb23473ed2abb6645d8474
4
+ data.tar.gz: 056bc404d1dc040ff8e22ed0e5c2ecf73fcc6e1d4b153a55798e06655ea86010
5
5
  SHA512:
6
- metadata.gz: 302521fed40c327d673c7c1c15fe8630d1005b3dcdefbe949d99edb54fab6f1635cd5e5ef80c535016579258031e6a232d21f94f459c71ef9a719896d68dc663
7
- data.tar.gz: 4c8113a176680fa522982678be6643c3416f0aebea0564f69289d0555fed84de3192f3d2b2e6ed295ef933ae684ecd04d3ad8f3d9feb1557f51864a4e8d2024e
6
+ metadata.gz: 782e8db8febe1997329346b92f318d177724b373c8a88aa6c02eef709d6f1eebb9bdb777004bde176f76c6eb5e8d1fddee46ddd867be03a7bdae61a1c4374d74
7
+ data.tar.gz: 585d087f78528a3b64a378c38084a01fe503c426a8d2758f93fd549b1e56172fc8def14de674c370ce2cd99f4543d6fc15bb601d6a66142e7df136d864a84fc0
data/README.md CHANGED
@@ -19,7 +19,7 @@ Add this line to your Rails application's Gemfile:
19
19
 
20
20
  ```ruby
21
21
  group :development, :test do
22
- gem 'integration_tests_rails', require: false
22
+ gem 'integration_tests_rails'
23
23
  end
24
24
  ```
25
25
 
@@ -34,16 +34,14 @@ bundle install
34
34
  After installation, run:
35
35
 
36
36
  ```sh
37
- rails generate integration_tests_rails:install
37
+ rails integration_tests_rails:install
38
38
  ```
39
39
 
40
40
  If you do not have `Yarn` installed, the above command will prompt you to install it. Follow the instructions to complete the installation. Re-run the command after installing `Yarn`.
41
41
 
42
42
  The generator will do the following:
43
43
  - Install Instanbul using Yarn.
44
- - Create a controller that can be used to *unit test JavaScript code*.
45
- - Add a line in `routes.rb` to route requests to the above controller.
46
- - Add an entry in `.gitignore` to ignore coverage reports and locally installed Istanbul packages.
44
+ - Add entries in `.gitignore` to ignore coverage reports and locally installed Istanbul packages.
47
45
 
48
46
  ### Configuration
49
47
 
@@ -56,8 +54,6 @@ require 'rails_helper'
56
54
  require 'integration_tests_rails'
57
55
 
58
56
  IntegrationTestsRails.setup
59
-
60
- require_relative 'features/tests_controller' # Loads the controller for unit testing JavaScript.
61
57
  ```
62
58
 
63
59
  The `IntegrationTestsRails.setup` method accepts an optional block for further customization. Below is an example how to use and contains the default values:
@@ -71,6 +67,7 @@ IntegrationTestsRails.setup do |config|
71
67
  config.server_host = '0.0.0.0' # Host for the Puma server used by Cuprite.
72
68
  config.server_port = nil # Port for the Puma server used by Cuprite.
73
69
  config.source_dir = 'app/javascript' # Directory containing the JavaScript files to be instrumented.
70
+ config.tests_page_html = DEFAULT_HTML_CONTENT # HTML content used for the test page. More details below.
74
71
  config.verbose = false # Whether to enable verbose logging.
75
72
  config.wait_time = 5 # Max time in seconds to wait after each request by Capybara to load content.
76
73
  config.window_size = [1920, 1080] # Size of the browser window used by Cuprite.
@@ -81,33 +78,29 @@ end
81
78
 
82
79
  ### Usage
83
80
 
84
- To unit test JavaScript code, the provided `TestsController (spec/support/features/tests_controller)` can be modified. By default, it only renders a complete HTML page that also loads importmap-supporting JavaScript code to set up the environment for testing.
81
+ To unit test JavaScript code, the gem will visit a test HTML page. By default, it only renders a complete HTML page that also loads importmap-supporting JavaScript code to set up the environment for testing.
85
82
 
86
83
  ```ruby
87
- class TestsController < ActionController::Base
88
- def index
89
- render inline: <<~HTML.squish
90
- <!DOCTYPE html>
91
- <html lang="en">
92
- <head>
93
- <meta charset="UTF-8">
94
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
95
- <meta name="turbo-visit-control" content="reload">
96
- <%= csrf_meta_tags %>
97
- <%= csp_meta_tag %>
98
- <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
99
- <%= stylesheet_link_tag 'custom', "data-turbo-track": "reload" %>
100
- <%= javascript_importmap_tags %>
101
- </head>
102
- <body>
103
- </body>
104
- </html>
105
- HTML
106
- end
107
- end
84
+ DEFAULT_HTML_CONTENT = <<~HTML.squish
85
+ <!DOCTYPE html>
86
+ <html lang="en">
87
+ <head>
88
+ <meta charset="UTF-8">
89
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
90
+ <meta name="turbo-visit-control" content="reload">
91
+ <%= csrf_meta_tags %>
92
+ <%= csp_meta_tag %>
93
+ <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
94
+ <%= stylesheet_link_tag 'custom', "data-turbo-track": "reload" %>
95
+ <%= javascript_importmap_tags %>
96
+ </head>
97
+ <body>
98
+ </body>
99
+ </html>
100
+ HTML
108
101
  ```
109
102
 
110
- Since vendored JavaScript are not included by default, additional tags may be required to load them. For example, if there exists a `custom_code.js` file in `app/javascript`:
103
+ Since vendored JavaScript are not included by default, additional tags may be required to load them. For example, if there exists a `custom_code.js` file in `app/javascript` and `vendor.min.js` file in `app/assets/javascripts/plugins`:
111
104
 
112
105
  ```ruby
113
106
  <<~HTML.squish
@@ -129,6 +122,7 @@ Since vendored JavaScript are not included by default, additional tags may be re
129
122
  </script>
130
123
  </head>
131
124
  <body>
125
+ <%= javascript_include_tag 'plugins/vendor.min' %>
132
126
  </body>
133
127
  </html>
134
128
  HTML
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'integration_tests_rails/version'
4
+ require_relative 'integration_tests_rails/railtie'
@@ -42,10 +42,12 @@ module IntegrationTestsRails
42
42
  end
43
43
 
44
44
  def configure_routes
45
- puts '================== ROUTES ADDED =================='
46
- Rails.application.routes.append do
45
+ app = Rails.application
46
+ app.routes.append do
47
47
  resources :tests, only: :index
48
48
  end
49
+ app.routes_reloader.reload!
50
+ log 'Routes appended and reloaded.'
49
51
  end
50
52
 
51
53
  def verbose?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '0.2.6'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'integration_tests_rails/version'
4
- require_relative 'integration_tests_rails/railtie'
5
3
  require_relative 'integration_tests_rails/configuration'
6
4
  require_relative 'integration_tests_rails/istanbul'
7
5
  require_relative 'integration_tests_rails/capybara'
@@ -13,10 +11,6 @@ module IntegrationTestsRails
13
11
  @configuration ||= Configuration.new
14
12
  end
15
13
 
16
- def configure
17
- yield(configuration)
18
- end
19
-
20
14
  def reset_configuration!
21
15
  @configuration = Configuration.new
22
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integration-tests-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien
@@ -87,6 +87,7 @@ extra_rdoc_files: []
87
87
  files:
88
88
  - MIT-LICENSE
89
89
  - README.md
90
+ - lib/integration-tests-rails.rb
90
91
  - lib/integration_tests_rails.rb
91
92
  - lib/integration_tests_rails/capybara.rb
92
93
  - lib/integration_tests_rails/capybara/helpers.rb