rspec-xlsx_matchers 0.1.4 → 0.1.5

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: 1d8b4869cb9ba13521a0fb6c7409529b38d851ec128f14a3cd950af6d068d06f
4
+ data.tar.gz: f96fcd5425130346a4d1b87b74cf30750aba7154666de460957254cdb773efd7
5
5
  SHA512:
6
- metadata.gz: c7ce34db6bac2e363f5a297ad303ba444187108a1e1bda7da2bcc2c69bc89342e955387fff18a611ac2799eac59a2a23282444629894761e50b2f1be8402f716
7
- data.tar.gz: 842250df331a05307531e830445c4d88422e900235a8f5dffb48cbccab42e4c4764622fea5ef25c5902d1810e8b787cce84c22146060fce6039b1a4966e3c422
6
+ metadata.gz: 9c497074ce7506bef2dfe726e1059a13a90abb349faf1968453919af0554efe316fe5b3fe22c92b11602c3a545e457e8aa28e3ec43d7407398ce3ed8a2bd67fd
7
+ data.tar.gz: 7adccbe837d24b02415a52f4087a132a4554dfccb139ae53fb493ed309d358009cab17f5e399dbc2846b5023fc9d0f72f74528c3976ec541002823b4d0d3200b
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module XlsxMatchers
5
+ # filled rows count matcher
6
+ class RowsWithData < 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.5"
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/rows_with_data"
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_rows_with_data
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_rows_with_data(count)
67
+ RowsWithData.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.5
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
@@ -45,6 +45,7 @@ files:
45
45
  - lib/rspec/xlsx_matchers/exact_match.rb
46
46
  - lib/rspec/xlsx_matchers/in_column.rb
47
47
  - lib/rspec/xlsx_matchers/in_row.rb
48
+ - lib/rspec/xlsx_matchers/rows_with_data.rb
48
49
  - lib/rspec/xlsx_matchers/sheets.rb
49
50
  - lib/rspec/xlsx_matchers/utils.rb
50
51
  - lib/rspec/xlsx_matchers/version.rb