rspec-xlsx_matchers 0.1.4 → 0.1.5
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/rspec/xlsx_matchers/rows_with_data.rb +49 -0
- data/lib/rspec/xlsx_matchers/version.rb +1 -1
- data/lib/rspec/xlsx_matchers.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d8b4869cb9ba13521a0fb6c7409529b38d851ec128f14a3cd950af6d068d06f
|
4
|
+
data.tar.gz: f96fcd5425130346a4d1b87b74cf30750aba7154666de460957254cdb773efd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/rspec/xlsx_matchers.rb
CHANGED
@@ -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
|
+
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-
|
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
|