integration-tests-rails 1.1.3 → 1.1.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: 384f4f3272d0ff29fee4b9a2d6bc580eec97967dcfaa195735c24dc147d56a01
4
- data.tar.gz: 8748fcb21a1a74c012254bc9cc1f219c3cf43ab1dfcf5051965e000f7d1893ea
3
+ metadata.gz: 3020cc3bc2a7fdcda72ea6b7fd12bb5786b4f26b1be3ff1c8533ff6a3046de3a
4
+ data.tar.gz: 3603ab4f58a7b508879fda0c91901142f22c39df3894013a54e4e88e8809b396
5
5
  SHA512:
6
- metadata.gz: 9e97a327ac819b6fd3155ea5366e959119a25305e6f5db0dbf994bfeaf1be26b621f6d22d5987708f272bca15672a9c9f0e13efdde1c41590c5af3724ca07f05
7
- data.tar.gz: 99848ce892f5abc64e4282d02f2e360e370e2b1c0495e2d470aed7882a6b0bf0b60aea227e0cc9a24577be30c9bfb224730e37329f1be828443d6c456a5ce9b5
6
+ metadata.gz: '032484b408cd1cfc672d6e0dfa379b1e3d01866546a750cb98d7d45d3e098941c79f77621f5431e41a2008ed1a45e0b299f38a18fe78a1a39496c2d5a00ddba7'
7
+ data.tar.gz: 8612c1eb1ac54ba15c2f63f236b85d07e93783f57d0fbbcdd39e2ddc6dd8521d9402bd15d53e600210f44009a7f923103a97153e6b88dbeb4a6aeee5eb745978
data/README.md CHANGED
@@ -63,6 +63,7 @@ The `IntegrationTestsRails.setup` method accepts an optional block for further c
63
63
  ```ruby
64
64
  IntegrationTestsRails.setup do |config|
65
65
  config.chrome_url = nil # Used for remote Chrome instances. Needs remote to be true.
66
+ config.js_coverage = true # Whether to enable JavaScript coverage using Istanbul.
66
67
  config.max_server_retries = 1000 # Before running the tests, Cuprite starts a server to communicate with Chrome. This sets the maximum number of retries to connect to that server.
67
68
  config.puma_threads = '1:1' # Number of threads for the Puma server used by Cuprite.
68
69
  config.remote = false # Whether to use a remote Chrome instance.
@@ -254,7 +255,7 @@ end
254
255
 
255
256
  ## JavaScript Coverage Reports
256
257
 
257
- After the tests (successful, failed or cancelled), coverage reports will be generated in `coverage/javascript` by default.
258
+ After the tests (successful, failed or cancelled), coverage reports will be generated in `coverage/javascript` by default. This can be disabled in the configuration by setting `js_coverage` to `false`. Be sure to uninstall Istanbul packages through the rake task `rake integration_tests_rails:istanbul:uninstall` if you do not need this feature.
258
259
 
259
260
  ## Example Setups
260
261
 
@@ -37,9 +37,9 @@ module IntegrationTestsRails
37
37
  </html>
38
38
  HTML
39
39
 
40
- attr_accessor :source_dir, :output_dir, :backup_dir, :coverage_path, :wait_time, :remote,
41
- :chrome_url, :tests_page_html, :window_size, :max_server_retries,
42
- :verbose, :timeout, :server_host, :server_port, :puma_threads, :experimental_features,
40
+ attr_accessor :source_dir, :output_dir, :backup_dir, :coverage_path, :wait_time, :remote, :chrome_url, :window_size,
41
+ :tests_page_html, :max_server_retries, :verbose, :js_coverage,
42
+ :timeout, :server_host, :server_port, :puma_threads, :experimental_features,
43
43
  :retry_attempts, :retry_sleep_duration, :retry_capture_exceptions
44
44
 
45
45
  def initialize
@@ -47,6 +47,7 @@ module IntegrationTestsRails
47
47
  @chrome_url = nil
48
48
  @coverage_path = 'coverage/nyc'
49
49
  @experimental_features = false
50
+ @js_coverage = true
50
51
  @max_server_retries = 1000
51
52
  @output_dir = 'tmp/instrumented_js'
52
53
  @puma_threads = '1:1'
@@ -9,14 +9,22 @@ module IntegrationTestsRails
9
9
  module Istanbul
10
10
  class << self
11
11
  def setup
12
- Util.configure_rspec
12
+ if IntegrationTestsRails.configuration.js_coverage
13
+ Util.configure_rspec
14
+ else
15
+ Util.log('JS coverage is disabled, skipping Istanbul setup.')
16
+ end
13
17
  end
14
18
  end
15
19
 
16
20
  # Ensure cleanup at exit, either success, failure or cancellation.
17
21
  at_exit do
18
- Collector.generate_report
19
- Collector.restore_original_files
22
+ if IntegrationTestsRails.configuration.js_coverage
23
+ Collector.generate_report
24
+ Collector.restore_original_files
25
+ else
26
+ Util.log('JS coverage is disabled, skipping Istanbul cleanup.')
27
+ end
20
28
  rescue StandardError => e
21
29
  warn "Istanbul cleanup failed: #{e.message}"
22
30
  end
@@ -37,6 +37,35 @@ module IntegrationTestsRails
37
37
 
38
38
  puts 'Integration tests environment setup complete.'
39
39
  end
40
+
41
+ namespace :istanbul do
42
+ desc 'Remove Istanbul installation.'
43
+ task uninstall: :environment do
44
+ puts 'Removing Istanbul...'
45
+ system('yarn remove istanbul-lib-instrument istanbul-lib-coverage istanbul-lib-report istanbul-reports')
46
+ puts 'Istanbul removed. '
47
+
48
+ if File.exist?('.gitignore')
49
+ content = File.read('.gitignore')
50
+ new_content = content.dup
51
+ lines_to_remove = ['tmp/instrumented_js/', 'tmp/js_backup/']
52
+ lines_to_remove.each do |line|
53
+ if content.include?(line)
54
+ new_content = new_content.gsub("#{line}\n", '')
55
+ puts "Removed '#{line}' from .gitignore."
56
+ else
57
+ puts "'#{line}' not found in .gitignore. Skipping."
58
+ end
59
+ end
60
+ if new_content == content
61
+ puts 'No changes made to .gitignore.'
62
+ else
63
+ File.write('.gitignore', new_content)
64
+ puts '.gitignore updated.'
65
+ end
66
+ end
67
+ end
68
+ end
40
69
  end
41
70
  end
42
71
  # rubocop:enable Metrics/BlockLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '1.1.3'
4
+ VERSION = '1.1.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.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien