rspec-xlsx_matchers 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1465d990a256a7f4407284c21bf2f656a369d5008d7c2b9c2df053be9f07d01
4
- data.tar.gz: a46a178d9225158efb189a3387d2941b60afee46dc84a45ae3616aa70f11e36f
3
+ metadata.gz: 3194c4fdcb2c56345d805ec5fc8a2e14d80311363738c155e1bef5d56d63929c
4
+ data.tar.gz: 9cbd5ed284576fa3482138931566c491ad906bc4bfb4311a0cdecfd1c0e30bdd
5
5
  SHA512:
6
- metadata.gz: c7ce34db6bac2e363f5a297ad303ba444187108a1e1bda7da2bcc2c69bc89342e955387fff18a611ac2799eac59a2a23282444629894761e50b2f1be8402f716
7
- data.tar.gz: 842250df331a05307531e830445c4d88422e900235a8f5dffb48cbccab42e4c4764622fea5ef25c5902d1810e8b787cce84c22146060fce6039b1a4966e3c422
6
+ metadata.gz: 3fd3eda4f88b0a0a7af9048f8d3aa8376c1a9cc2338cf2a09db2030e8715463e27addff64bc0fedf7ebb37b7c8ba724cd7e9af1c08000727d6efd0dcdfa29a99
7
+ data.tar.gz: eda173dc8ccc0052bc66fb5013a206c03f25cd11cc5753bfcd622b52ebc5d9c2fc3dc14279f28300e45f244a5da119c245627a5230e6b71de5961f307ab52f7b
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module XlsxMatchers
5
+ # filled rows count matcher
6
+ class FilledRows < BaseSheet
7
+ attr_reader :expected_filled_row_count
8
+
9
+ def initialize(count)
10
+ super()
11
+ @expected_filled_row_count = count
12
+ end
13
+
14
+ def matches?(subject)
15
+ @subject = subject
16
+ @sheet = find_sheet
17
+ return false if sheet.nil?
18
+
19
+ actual_filled_row_count == expected_filled_row_count
20
+ end
21
+
22
+ def failure_message
23
+ return sheet_failure_message if sheet.nil?
24
+
25
+ "Expected #{expected_filled_row_count} filled rows but found #{actual_filled_row_count}"
26
+ end
27
+
28
+ def failure_message_when_negated
29
+ return sheet_failure_message if sheet.nil?
30
+
31
+ "Expected NOT to find #{expected_filled_row_count} filled rows but did"
32
+ end
33
+
34
+ private
35
+
36
+ def actual_filled_row_count
37
+ @actual_filled_row_count ||= process_sheet
38
+ end
39
+
40
+ def process_axlsx_sheet
41
+ sheet.rows.compact.count { |row| !row.nil? && !row.empty? }
42
+ end
43
+
44
+ def process_roo_sheet
45
+ (1..sheet.last_row).count { |index| !sheet.row(index).compact.empty? }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module XlsxMatchers
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  end
@@ -12,6 +12,7 @@ require_relative "xlsx_matchers/columns"
12
12
  require_relative "xlsx_matchers/empty_row"
13
13
  require_relative "xlsx_matchers/cells"
14
14
  require_relative "xlsx_matchers/cell_value"
15
+ require_relative "xlsx_matchers/filled_rows"
15
16
 
16
17
  begin
17
18
  require "roo"
@@ -32,6 +33,7 @@ module RSpec
32
33
  # - have_excel_empty_row
33
34
  # - have_excel_cells
34
35
  # - have_excel_cell_value
36
+ # - have_excel_filled_rows
35
37
  module XlsxMatchers
36
38
  # class Error < StandardError; end
37
39
 
@@ -60,5 +62,9 @@ module RSpec
60
62
  def have_excel_cell_value(value)
61
63
  CellValue.new(value)
62
64
  end
65
+
66
+ def have_excel_filled_rows(count)
67
+ FilledRows.new(count)
68
+ end
63
69
  end
64
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-xlsx_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - drvn-eb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-18 00:00:00.000000000 Z
11
+ date: 2024-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -43,6 +43,7 @@ files:
43
43
  - lib/rspec/xlsx_matchers/columns.rb
44
44
  - lib/rspec/xlsx_matchers/empty_row.rb
45
45
  - lib/rspec/xlsx_matchers/exact_match.rb
46
+ - lib/rspec/xlsx_matchers/filled_rows.rb
46
47
  - lib/rspec/xlsx_matchers/in_column.rb
47
48
  - lib/rspec/xlsx_matchers/in_row.rb
48
49
  - lib/rspec/xlsx_matchers/sheets.rb