Class: MySQLExpectations::Matchers::HaveEngineType

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql_expectations/matchers/table_have_engine_type.rb

Overview

A matcher that check a table’s engine type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_engine_type) ⇒ HaveEngineType

Returns a new instance of HaveEngineType.



12
13
14
15
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 12

def initialize(expected_engine_type)
  @expected_engine_type = expected_engine_type
  @table = nil
end

Instance Attribute Details

#expected_engine_typeObject (readonly)

Returns the value of attribute expected_engine_type.



10
11
12
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 10

def expected_engine_type
  @expected_engine_type
end

#tableObject (readonly)

Returns the value of attribute table.



10
11
12
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 10

def table
  @table
end

Instance Method Details

#actual_engine_typeObject



17
18
19
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 17

def actual_engine_type
  table.engine_type
end

#descriptionObject



26
27
28
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 26

def description
  "have engine type '#{expected_engine_type}'"
end

#failure_messageObject



30
31
32
33
34
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 30

def failure_message
  "expected '#{table.name}' table engine type to be " \
    "'#{expected_engine_type}' " \
    "but it was '#{actual_engine_type}'"
end

#matches?(table) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/mysql_expectations/matchers/table_have_engine_type.rb', line 21

def matches?(table)
  @table = table
  actual_engine_type == expected_engine_type
end