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

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/dm-migrations-0.9.9/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.



48
49
50
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 48

def initialize(column_name)
  @column_name = column_name
end

Instance Attribute Details

#column_nameObject

Returns the value of attribute column_name.



46
47
48
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 46

def column_name
  @column_name
end

#tableObject

Returns the value of attribute table.



46
47
48
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 46

def table
  @table
end

Instance Method Details

#failure_messageObject



57
58
59
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 57

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

#matches?(table) ⇒ Boolean

Returns:



52
53
54
55
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 52

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

#negative_failure_messageObject



61
62
63
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 61

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