Class: RSpec::XlsxMatchers::Cells
- Includes:
- InRow
- Defined in:
- lib/rspec/xlsx_matchers/cells.rb
Overview
have_excel_cells
Constant Summary collapse
- EXPECTED =
"Expected"
- RECEIVED =
"Received"
Instance Attribute Summary collapse
-
#actual_cells ⇒ Object
readonly
Returns the value of attribute actual_cells.
-
#expected_cells ⇒ Object
readonly
Returns the value of attribute expected_cells.
-
#mismatch_indexes ⇒ Object
readonly
Returns the value of attribute mismatch_indexes.
Attributes included from InRow
Attributes inherited from BaseSheet
Instance Method Summary collapse
-
#failure_message ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(expected_cells) ⇒ Cells
constructor
A new instance of Cells.
Methods included from InRow
Methods inherited from BaseSheet
Methods included from Utils
Constructor Details
#initialize(expected_cells) ⇒ Cells
Returns a new instance of Cells.
13 14 15 16 17 18 |
# File 'lib/rspec/xlsx_matchers/cells.rb', line 13 def initialize(expected_cells) super() @expected_cells = force_array(expected_cells) @actual_cells = [] @mismatch_indexes = [] end |
Instance Attribute Details
#actual_cells ⇒ Object (readonly)
Returns the value of attribute actual_cells.
8 9 10 |
# File 'lib/rspec/xlsx_matchers/cells.rb', line 8 def actual_cells @actual_cells end |
#expected_cells ⇒ Object (readonly)
Returns the value of attribute expected_cells.
8 9 10 |
# File 'lib/rspec/xlsx_matchers/cells.rb', line 8 def expected_cells @expected_cells end |
#mismatch_indexes ⇒ Object (readonly)
Returns the value of attribute mismatch_indexes.
8 9 10 |
# File 'lib/rspec/xlsx_matchers/cells.rb', line 8 def mismatch_indexes @mismatch_indexes end |
Instance Method Details
#failure_message ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rspec/xlsx_matchers/cells.rb', line 20 def # rubocop:disable Metrics/AbcSize, Metrics/MethodLength return if sheet.nil? return if row.nil? = (String.new("Rows did not match : \n")) # Cells content expected_cells.each_with_index do |expected_cell, idx| sizeof_actual_cell = actual_cells[idx].to_s.size sizeof_expected_cell = expected_cell.to_s.size << " #{idx}" << (" " * (4 - idx.to_s.size)) << "| #{actual_cells[idx]}" << (" " * (biggest_actual_cell_size - sizeof_actual_cell)) << " | #{expected_cell}" << (" " * (biggest_expected_cell_size - sizeof_expected_cell)) << " | #{mismatch_indexes.include?(idx) ? "<----- Mismatch" : ""}" << "\n" end end |