integration-tests-rails 1.0.3 → 1.0.4

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: 07f7241b5d554a5e0409bf4d955b5bcb859126f394e7eed5513ba6f92a9b3318
4
- data.tar.gz: 72e0af62570e42a128cbd906b8874e30e69c0e419e898cacc96b936b0f4f3d56
3
+ metadata.gz: be57f4d8d66105663b9c082866bcade277fceec8e89254bfd5fa88d3c6c6ec0d
4
+ data.tar.gz: 0c45dd9db327c01f8e93a6c92c327d45153cdc8ca8ba6a172190d809661490e3
5
5
  SHA512:
6
- metadata.gz: 9bb1e5c7734164e053e45ab9a0fc17d7134d9a0b525351cafda5812110a26594fac0a363a8d1d415db849394f6d3bc591193fda4a6dba1b8c3d89d253f70909a
7
- data.tar.gz: 23b0f92a2ecd62af9882abdfb48ca3cf751fd891ff0d6b28e2e39793e259a4b63e8069f0f85a35f65d7ad4c866ade47c1b6b18b888917e2b2b4b40a783ac3f2a
6
+ metadata.gz: 2aa3bbefef1c3ec24a53c9f6e1cd4c3ac2b0549f408b79aa1de3689503e39b96a7fca47a4ffcf61b6ebf9ff9e0f7d4bbf2fa417d5cb36b4b363e896bb9a1fcd0
7
+ data.tar.gz: a46a8871be677914d9faa52703006719a9ca097e8b5bac8503234ffb5752e6ef097c5d3267dd5df7facd30f0fd6479a8d8f8d023db4046b77b2d1400e5be3876
data/README.md CHANGED
@@ -176,6 +176,18 @@ let(:script) do
176
176
  end
177
177
  ```
178
178
 
179
+ There is a `function` component that is the same as the `script` component but `function` automatically wraps the containing JavaScript code in an arrow function and executes it. The above can be rewritten as:
180
+
181
+ ```ruby
182
+ let(:function) do
183
+ <<~JS
184
+ const value1 = CustomCode.getValue1();
185
+ const value2 = CustomCode.getValue2();
186
+ return CustomCode.combineValues(value1, value2);
187
+ JS
188
+ end
189
+ ```
190
+
179
191
  The above will successfully execute the three statements and return the value in `result`. However, this can become a problem if the JavaScript code being tested relies on waiting for each statement to complete. In such cases, it is recommended to use an array instead in `script`:
180
192
 
181
193
  ```ruby
@@ -191,8 +203,9 @@ let(:script) do
191
203
  end
192
204
  ```
193
205
 
194
- In such cases where `script` is an array, the `result` component will contain the return value of the **last statement only**.
206
+ In such cases where `script` is an array, the `result` component will contain the return value of the **last statement only**. `function` also supports arrays; each element will be wrapped in an arrow function and executed sequentially.
195
207
 
208
+ **Do not use `script` and `function` components as the same time in an example.**
196
209
 
197
210
  ## Integration Testing
198
211
 
@@ -15,7 +15,26 @@ module IntegrationTestsRails
15
15
  end
16
16
  end
17
17
 
18
- let(:script) { nil }
18
+ let(:script) do
19
+ case function
20
+ when Array
21
+ function.map! do |fn|
22
+ <<~JSCODE
23
+ (() => {
24
+ #{fn}
25
+ })();
26
+ JSCODE
27
+ end
28
+ when String
29
+ <<~JSCODE
30
+ (() => {
31
+ #{function}
32
+ })();
33
+ JSCODE
34
+ end
35
+ end
36
+
37
+ let(:function) { nil }
19
38
 
20
39
  before do
21
40
  visit tests_path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  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: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien