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 +4 -4
- data/lib/match_table/version.rb +1 -1
- data/lib/match_table.rb +28 -23
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70e0736d7e6389eb7a470f9922323641f5236002f8065031581493e3cc011c57
|
|
4
|
+
data.tar.gz: ebc4ee8936cbbb268288f7e2e96a49c4e01a7541128042631e4af3b57584e844
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff2d0a0be917a4271ec3f669a87d586d7c38f709dfe103d4f426e92b2c931a7bad8fa4e9b7d0d2fdd2cf5e1aeafc0064fb54e6e1b02c2ef6e778f7e9874588a4
|
|
7
|
+
data.tar.gz: a1acea2fee0bebd6fecd8e6d627f97ee001b6df6e8663b736f90d4d80383bc8f9f37be27f063efb27a7429a47745498d2932de28e863d8a6415cbd1becca43be
|
data/lib/match_table/version.rb
CHANGED
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
47
|
-
|
|
49
|
+
@actual = matched_rows
|
|
50
|
+
@expected_as_array = Array(@expected_rows)
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
62
|
-
|
|
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
|
|
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
|
-
|
|
114
|
-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2025-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec-expectations
|