Class: Spec::Matchers::Migration::HaveColumnMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/matchers/migration_matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_name) ⇒ HaveColumnMatcher

Returns a new instance of HaveColumnMatcher.



47
48
49
# File 'lib/spec/matchers/migration_matchers.rb', line 47

def initialize(column_name)
  @column_name = column_name
end

Instance Attribute Details

#column_nameObject

Returns the value of attribute column_name.



45
46
47
# File 'lib/spec/matchers/migration_matchers.rb', line 45

def column_name
  @column_name
end

#tableObject

Returns the value of attribute table.



45
46
47
# File 'lib/spec/matchers/migration_matchers.rb', line 45

def table
  @table
end

Instance Method Details

#failure_messageObject



56
57
58
# File 'lib/spec/matchers/migration_matchers.rb', line 56

def failure_message
  %(expected #{table} to have column '#{column_name}')
end

#matches?(table) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/spec/matchers/migration_matchers.rb', line 51

def matches?(table)
  @table = table
  table.columns.map { |c| c.name }.include?(column_name.to_s)
end

#negative_failure_messageObject



60
61
62
# File 'lib/spec/matchers/migration_matchers.rb', line 60

def negative_failure_message
  %(expected #{table} to not have column '#{column_name}')
end