dommy-rails 0.11.0 → 0.13.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: 50d6da0920fbd92140fcbba4bb15ca4a0b3290827746785c8d5c46e55caaab0c
4
- data.tar.gz: d9788d25d33b9d74b7bc7ff5e06e15b754391d0ab841de86f870282ca22dd6cb
3
+ metadata.gz: decdc2f02ac2d15f9f1447da1f008fd9b406bb3c423f16c70f7d1c1251d25b45
4
+ data.tar.gz: 61baf3154db33257f6e508ccc15b21c3274708ad1444fb13495d6bfff2cc4a24
5
5
  SHA512:
6
- metadata.gz: cbe6783f0111e3034bd2c26adb2a947f0b43337db68911679af0cdc7892a7a387a082f300c36fca0448b773b0b4cb509a77611fde462249207616c3d86985966
7
- data.tar.gz: f52246bc241b4a4e67e1fc3ac0fa3cc194bf42895c484291e38f98aedb00fe17cc653aee5482b0470622b357102d9b7facc08de1b59414f75a5499a839756624
6
+ metadata.gz: 55439022b061482154d59c057654a8010edf7f7c1cf430cae0edfc4eb91e23822ea779d97acbe128820519642e699c4fd8fa2918e584d05503eae401fb66b3a2
7
+ data.tar.gz: 5f307f03a7c9b6e745486ca6ef23a882ce0af09abe6d387708b21de98409aae35f6dc8fc90f0074ab62ee2fc947fb9bf7579c6e734383cc81a86eb9fe5d12e3c
@@ -75,8 +75,8 @@ module Dommy
75
75
  # Rails-internals spans (controller/SQL/render/job/mail) on every
76
76
  # traced request; idempotent, no-op without ActiveSupport.
77
77
  Dommy::Rails::TraceInstrumentation.install!
78
- ::Dommy::Rack::Session.new(dommy_browser_app, javascript: true, trace: true, trace_dom: true,
79
- trace_snapshots: true)
78
+ ::Dommy::Rack::Session.new(dommy_browser_app, javascript: true, strict_js_errors: true,
79
+ trace: true, trace_dom: true, trace_snapshots: true)
80
80
  end
81
81
  end
82
82
 
@@ -87,25 +87,24 @@ module Dommy
87
87
 
88
88
  # Suppress strict JS-error failure for errors raised inside the block (they
89
89
  # stay in `browser.js_errors`). For specs that intentionally trigger one.
90
- def allow_js_errors
91
- @dommy_allow_js_errors = true
92
- yield
93
- ensure
94
- dommy_browser_ack_js_errors
90
+ # A page that handles its own errors needs nothing here: it never reaches
91
+ # the log, just as it never reaches a browser console.
92
+ def allow_js_errors(&block)
93
+ browser.allow_js_errors(&block)
95
94
  end
96
95
 
97
- # Dispose the browser and fail if uncaught JS errors were collected. Call
98
- # from a Minitest #teardown / RSpec after hook (the integration modules
99
- # wire this automatically).
96
+ # Dispose the browser, which fails the spec if the page left JS errors
97
+ # unhandled and nobody reported them. Call from a Minitest #teardown /
98
+ # RSpec after hook (the integration modules wire this automatically).
99
+ #
100
+ # The session checks at every step too, so a failure normally surfaces on
101
+ # the line that caused it; this catches whatever the last step produced.
100
102
  def dommy_browser_teardown
101
103
  return unless browser_started?
102
104
 
103
- pending = browser.js_errors[(@dommy_browser_acked || 0)..] || []
104
- browser.dispose
105
+ browser_to_dispose = browser
105
106
  @dommy_browser = nil
106
- return if @dommy_allow_js_errors || pending.empty?
107
-
108
- raise dommy_browser_js_error(pending)
107
+ browser_to_dispose.dispose
109
108
  end
110
109
 
111
110
  private
@@ -146,15 +145,6 @@ module Dommy
146
145
  slug = label.to_s.strip.downcase.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "")
147
146
  slug.empty? ? "example" : slug[0, 100]
148
147
  end
149
-
150
- def dommy_browser_ack_js_errors
151
- @dommy_browser_acked = browser_started? ? browser.js_errors.length : 0
152
- end
153
-
154
- def dommy_browser_js_error(errors)
155
- lines = errors.map { |e| " #{e.class}: #{e.message}" }
156
- RuntimeError.new("#{errors.length} uncaught JS error(s) during the spec:\n#{lines.join("\n")}")
157
- end
158
148
  end
159
149
  end
160
150
  end
@@ -1,5 +1,5 @@
1
1
  module Dommy
2
2
  module Rails
3
- VERSION = "0.11.0"
3
+ VERSION = "0.13.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dommy-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.11.0
18
+ version: 0.13.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.11.0
25
+ version: 0.13.0
26
26
  description: Rails-specific matchers and assertions for Dommy, including form helper
27
27
  understanding, Turbo Stream support, Stimulus attribute checking, and HTML quality
28
28
  linting.