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

- (HaveColumnMatcher) initialize(column_name)

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

- (Object) column_name

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

- (Object) table

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

- (Object) failure_message



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

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

- (Boolean) matches?(table)

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

- (Object) negative_failure_message



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