integration-tests-rails 0.2.7 → 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 +4 -4
- data/README.md +24 -30
- data/lib/integration-tests-rails.rb +4 -0
- data/lib/integration_tests_rails/version.rb +1 -1
- data/lib/integration_tests_rails.rb +0 -6
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cbfc69eebf1fd54a4b04781e9e269852aee8ef0aaeb23473ed2abb6645d8474
|
|
4
|
+
data.tar.gz: 056bc404d1dc040ff8e22ed0e5c2ecf73fcc6e1d4b153a55798e06655ea86010
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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'
|
|
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
|
|
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
|
-
-
|
|
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
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
@@ -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.
|
|
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
|