match_table 1.1.0 → 1.2.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: 77cc25bced0a709998c9d0f308811a3c0c339838082172d2c48e64191bbd72b7
4
- data.tar.gz: 69b3cb5768b9c6c1a0791b3fec61ce6bb2b18d3158990f713902e5d15df07ca5
3
+ metadata.gz: 70e0736d7e6389eb7a470f9922323641f5236002f8065031581493e3cc011c57
4
+ data.tar.gz: ebc4ee8936cbbb268288f7e2e96a49c4e01a7541128042631e4af3b57584e844
5
5
  SHA512:
6
- metadata.gz: ead9964e2f6d2338ec86963d66a30cb0d3bf0a343bf0a0cbfa3625222b76903c73afc9aa943e45a7d6b2f9eab2827099419e36fa809263c49f6d31be5e9521e2
7
- data.tar.gz: 853b507440493137c1df8e7d770b6fde5cd72a11f3ca71b2b215bb619d28ecbe2f4bafd9269a209c7f2637475d281f8f1c20d1cb106f3f9a4a56072084a42d2b
6
+ metadata.gz: ff2d0a0be917a4271ec3f669a87d586d7c38f709dfe103d4f426e92b2c931a7bad8fa4e9b7d0d2fdd2cf5e1aeafc0064fb54e6e1b02c2ef6e778f7e9874588a4
7
+ data.tar.gz: a1acea2fee0bebd6fecd8e6d627f97ee001b6df6e8663b736f90d4d80383bc8f9f37be27f063efb27a7429a47745498d2932de28e863d8a6415cbd1becca43be
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MatchTable
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/match_table.rb CHANGED
@@ -24,10 +24,10 @@ RSpec::Matchers.define :match_table do |table|
24
24
 
25
25
  raise ArgumentError, "all rows must have the same headers" unless same_headers
26
26
 
27
- begin
28
- # We'll rerun this block until our expectations are met or we time out.
29
- synchronize do
30
- @failures = []
27
+ # We'll rerun this block until our expectations are met or we time out.
28
+ synchronize do
29
+ @failures = []
30
+ begin
31
31
  find_elements_on_page
32
32
 
33
33
  header_positions =
@@ -42,27 +42,30 @@ RSpec::Matchers.define :match_table do |table|
42
42
  @actual_rows.each do |actual_row|
43
43
  matched_rows << match_row(header_positions:, actual_row:)
44
44
  end
45
+ rescue Capybara::ExpectationNotMet => e
46
+ raise "Internal match_table error: #{e.message}"
47
+ end
45
48
 
46
- @actual = matched_rows
47
- @expected_as_array = Array(@expected_rows)
49
+ @actual = matched_rows
50
+ @expected_as_array = Array(@expected_rows)
48
51
 
49
- # Grab the failures from these expectations so we can use their failure messages
50
- RSpec::Support.with_failure_notifier(append_to_failures_array_notifier) do
51
- case @mode
52
- when :exact
53
- expect(actual).to eq(expected_as_array)
54
- when :include
55
- expect(actual).to include(*expected_as_array)
56
- end
52
+ # Grab the failures from these expectations so we can use their failure messages
53
+ RSpec::Support.with_failure_notifier(append_to_failures_array_notifier) do
54
+ case @mode
55
+ when :exact
56
+ expect(actual).to eq(expected_as_array)
57
+ when :include
58
+ expect(actual).to include(*expected_as_array)
57
59
  end
58
-
59
- raise Capybara::ExpectationNotMet unless @failures.empty?
60
60
  end
61
- rescue Capybara::ExpectationNotMet
62
- false
61
+
62
+ # raise to signal to synchronize that we need to retry
63
+ raise Capybara::ExpectationNotMet unless @failures.empty?
63
64
  end
64
65
 
65
66
  @failures.empty?
67
+ rescue Capybara::ExpectationNotMet
68
+ false
66
69
  end
67
70
 
68
71
  # Match the table exactly with the provided rows in order.
@@ -108,12 +111,14 @@ RSpec::Matchers.define :match_table do |table|
108
111
  table = find_table(@table)
109
112
 
110
113
  @actual_headers =
111
- table.find("thead").all("th").map(&:text).compact_blank
114
+ table.find("thead").all("th", visible: :all).map do |element|
115
+ text = element.text
116
+ if text.blank?
117
+ text = element.first("[data-role]", visible: :all, minimum: 0)&.text(:all) || ""
118
+ end
112
119
 
113
- @actual_headers +=
114
- table.find("thead").all("th", visible: :hidden).map do |element|
115
- element.first("[data-role]").text(:all)
116
- end.compact_blank
120
+ text
121
+ end
117
122
 
118
123
  @actual_rows = []
119
124
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-expectations