Class: Spec::Matchers::Migration::HaveColumnMatcher
- Defined in:
- lib/gems/dm-migrations-0.9.9/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.
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_name ⇒ Object
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 |
#table ⇒ Object
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_message ⇒ Object
57 58 59 |
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 57 def %(expected #{table} to have column '#{column_name}') end |
#matches?(table) ⇒ Boolean
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_message ⇒ Object
61 62 63 |
# File 'lib/gems/dm-migrations-0.9.9/lib/spec/matchers/migration_matchers.rb', line 61 def %(expected #{table} to not have column '#{column_name}') end |