Class: MySQLExpectations::Matchers::TableHaveCollation

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

Overview

A matcher that checks a table’s collation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_collation) ⇒ TableHaveCollation

Returns a new instance of TableHaveCollation.



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

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

Instance Attribute Details

#expected_collationObject (readonly)

Returns the value of attribute expected_collation.



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

def expected_collation
  @expected_collation
end

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

Instance Method Details

#actual_collationObject



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

def actual_collation
  table.collation
end

#descriptionObject



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

def description
  "have collation '#{expected_collation}'"
end

#failure_messageObject



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

def failure_message
  "expected '#{table.name}' table to have collation " \
    "'#{expected_collation}' but it was '#{table.collation}'"
end

#matches?(table) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(table)
  @table = table
  actual_collation == expected_collation
end