Class: RSpec::XlsxMatchers::CellValue

Inherits:
BaseSheet
  • Object
show all
Includes:
InColumn, InRow
Defined in:
lib/rspec/xlsx_matchers/cell_value.rb

Overview

have_excel_cell_value

Instance Attribute Summary collapse

Attributes included from InColumn

#column_name

Attributes included from InRow

#row_index

Attributes inherited from BaseSheet

#sheet, #sheet_name, #subject

Instance Method Summary collapse

Methods included from InColumn

#in_column, #in_column_by_index

Methods included from InRow

#in_row

Methods inherited from BaseSheet

#in_sheet, #matches?

Methods included from Utils

#force_array, #map_output

Constructor Details

#initialize(expected_value) ⇒ CellValue

Returns a new instance of CellValue.



11
12
13
14
# File 'lib/rspec/xlsx_matchers/cell_value.rb', line 11

def initialize(expected_value)
  super()
  @expected_value = expected_value
end

Instance Attribute Details

#actual_valueObject (readonly)

Returns the value of attribute actual_value.



9
10
11
# File 'lib/rspec/xlsx_matchers/cell_value.rb', line 9

def actual_value
  @actual_value
end

#expected_valueObject (readonly)

Returns the value of attribute expected_value.



9
10
11
# File 'lib/rspec/xlsx_matchers/cell_value.rb', line 9

def expected_value
  @expected_value
end

Instance Method Details

#failure_messageObject



16
17
18
19
20
21
22
23
24
# File 'lib/rspec/xlsx_matchers/cell_value.rb', line 16

def failure_message
  return sheet_failure_message if sheet.nil?
  return header_column_not_found_message if header_column_not_found?
  return row_not_found_message if row_not_found?
  return column_not_found_message if column_not_found?

  "Mismatch cell value in column #{failure_message_in_column} of row '#{row_index}': " \
    "expected: '#{expected_value}', received: '#{actual_value}'"
end

#failure_message_in_columnObject



26
27
28
29
30
31
32
# File 'lib/rspec/xlsx_matchers/cell_value.rb', line 26

def failure_message_in_column
  if column_name.nil?
    "column with index #{column_index}"
  else
    "column '#{column_name}'"
  end
end