Class: Spec::Matchers::Migration::HaveColumnMatcher
- Inherits:
-
Object
- Object
- Spec::Matchers::Migration::HaveColumnMatcher
- Defined in:
- lib/spec/matchers/migration_matchers.rb
Instance Attribute Summary collapse
-
#column_name ⇒ Object
Returns the value of attribute column_name.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(column_name) ⇒ HaveColumnMatcher
constructor
A new instance of HaveColumnMatcher.
- #matches?(table) ⇒ Boolean
- #negative_failure_message ⇒ Object
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_name ⇒ Object
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 |
#table ⇒ Object
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_message ⇒ Object
56 57 58 |
# File 'lib/spec/matchers/migration_matchers.rb', line 56 def %(expected #{table} to have column '#{column_name}') end |
#matches?(table) ⇒ 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_message ⇒ Object
60 61 62 |
# File 'lib/spec/matchers/migration_matchers.rb', line 60 def %(expected #{table} to not have column '#{column_name}') end |