Class: MySQLExpectations::Field

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

Overview

Allows assertions on a database

Instance Method Summary collapse

Constructor Details

#initialize(field_element) ⇒ Field

Returns a new instance of Field.



9
10
11
# File 'lib/mysql_expectations/field.rb', line 9

def initialize(field_element)
  @field_element = field_element
end

Instance Method Details

#definition?(expected_options) ⇒ Boolean Also known as: has_definition?

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'lib/mysql_expectations/field.rb', line 17

def definition?(expected_options)
  expected_options.each do |expected_key, expected_value|
    value = @field_element.attributes[expected_key]
    return false if value.nil? || value != expected_value
  end
  true
end

#nameObject



13
14
15
# File 'lib/mysql_expectations/field.rb', line 13

def name
  @field_element.attributes['Field']
end

#nullable?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/mysql_expectations/field.rb', line 37

def nullable?
  @field_element.attributes['Null'] == 'YES'
end

#typeObject



27
28
29
# File 'lib/mysql_expectations/field.rb', line 27

def type
  @field_element.attributes['Type']
end

#type?(expected_type) ⇒ Boolean Also known as: has_type?

Returns:

  • (Boolean)


31
32
33
# File 'lib/mysql_expectations/field.rb', line 31

def type?(expected_type)
  expected_type == type
end