match_table 1.2.0 → 1.3.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: 70e0736d7e6389eb7a470f9922323641f5236002f8065031581493e3cc011c57
4
- data.tar.gz: ebc4ee8936cbbb268288f7e2e96a49c4e01a7541128042631e4af3b57584e844
3
+ metadata.gz: 318e51a75753d999304e5a8c93a9eee0e71c1ed9eaa08ee804dfffa9bba74c02
4
+ data.tar.gz: 34480da0ff98a9aa86b728c7b5cd458cd8a8d7f74d5770036f625410dc926010
5
5
  SHA512:
6
- metadata.gz: ff2d0a0be917a4271ec3f669a87d586d7c38f709dfe103d4f426e92b2c931a7bad8fa4e9b7d0d2fdd2cf5e1aeafc0064fb54e6e1b02c2ef6e778f7e9874588a4
7
- data.tar.gz: a1acea2fee0bebd6fecd8e6d627f97ee001b6df6e8663b736f90d4d80383bc8f9f37be27f063efb27a7429a47745498d2932de28e863d8a6415cbd1becca43be
6
+ metadata.gz: 75606e33fd7e0a64726484d93259c6753b8655bbe69e8a7f869ea055a8e095ce1238d7c886d6792ed71c360925975f7d3a8fc6e6fb048a58fef7d6b9d20ac769
7
+ data.tar.gz: e3f7ce2500136ed5b189504b079c3beb34ad119f81fbc36c65a206a369a7e75d6e3104d45bd7be53b129bc86ceadf446c51e9b04c442b63e67d40838f161e251
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.3.0] - 2026-01-16
4
+
5
+ - Match on entire header instead of prefix (#3)
6
+
7
+ ## [1.2.0] - 2025-11-18
8
+
9
+ - Rework hidden header support (#2)
10
+ - Fix an issue where match_table could eat failures (#2)
11
+
12
+ ## [1.1.0] - 2025-09-29
13
+
14
+ - Include hidden headers if they have a child with data-role (#1)
15
+
3
16
  ## [1.0.0] - 2025-04-15
4
17
 
5
18
  - Initial release
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
4
5
  require "standard/rake"
5
6
 
6
- task default: :standard
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: [:spec, :standard]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MatchTable
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/match_table.rb CHANGED
@@ -32,7 +32,7 @@ RSpec::Matchers.define :match_table do |table|
32
32
 
33
33
  header_positions =
34
34
  expected_headers.each_with_object({}) do |header, hash|
35
- position = @actual_headers.find_index { |actual_header| actual_header.start_with?(header) }
35
+ position = @actual_headers.find_index { |actual_header| actual_header == header }
36
36
  unless position.nil?
37
37
  hash[header] = position
38
38
  end
@@ -113,17 +113,25 @@ RSpec::Matchers.define :match_table do |table|
113
113
  @actual_headers =
114
114
  table.find("thead").all("th", visible: :all).map do |element|
115
115
  text = element.text
116
- if text.blank?
116
+ if text.nil? || text.empty?
117
117
  text = element.first("[data-role]", visible: :all, minimum: 0)&.text(:all) || ""
118
118
  end
119
119
 
120
- text
120
+ normalize_header_text(text)
121
121
  end
122
122
 
123
123
  @actual_rows = []
124
124
 
125
- rows = table.find("tbody:not(.contents)").all("tr[data-table-target='row']:not([data-accordion-content] table tr)").presence ||
126
- table.find("tbody:not(.contents)").all("tr[data-table-target='row']")
125
+ tbody = table.find("tbody:not(.contents)")
126
+ rows = tbody.all("tr[data-table-target='row']")
127
+
128
+ # Filter out rows that are inside accordion content of table rows
129
+ # Only reject rows that are inside a tr[data-accordion-content] that is within this specific table
130
+ rows = rows.reject do |row|
131
+ row.ancestor("tr[data-accordion-content]", minimum: 0)
132
+ rescue Capybara::ElementNotFound
133
+ false
134
+ end
127
135
 
128
136
  rows.each do |row|
129
137
  cells = row.all("td")
@@ -137,6 +145,15 @@ RSpec::Matchers.define :match_table do |table|
137
145
  end
138
146
  end
139
147
 
148
+ def normalize_header_text(text)
149
+ return text if text.nil? || text.empty?
150
+
151
+ text
152
+ .gsub(/arrow_drop_(up|down)/, "")
153
+ .gsub(/\s+/, " ")
154
+ .strip
155
+ end
156
+
140
157
  def append_to_failures_array_notifier
141
158
  lambda { |failure, _opts| @failures << failure }
142
159
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-11-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec-expectations
@@ -60,7 +59,6 @@ metadata:
60
59
  allowed_push_host: https://rubygems.org
61
60
  homepage_uri: https://github.com/detaso/match_table
62
61
  source_code_uri: https://github.com/detaso/match_table
63
- post_install_message:
64
62
  rdoc_options: []
65
63
  require_paths:
66
64
  - lib
@@ -75,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
73
  - !ruby/object:Gem::Version
76
74
  version: '0'
77
75
  requirements: []
78
- rubygems_version: 3.5.22
79
- signing_key:
76
+ rubygems_version: 3.7.2
80
77
  specification_version: 4
81
78
  summary: Adds a `match_table` matcher for your Capybara system specs.
82
79
  test_files: []