Module: RSpec::RubyContentMatchers::ActiveRecord::Migration
- Defined in:
- lib/migration-spec/matchers/content/have_column.rb
Instance Method Summary collapse
- #have_add_column(name, type = 'string') ⇒ Object (also: #have_column)
- #have_change_column(name, type = 'string') ⇒ Object
- #have_columns(columns = {}) ⇒ Object
- #have_remove_column(name) ⇒ Object
- #have_timestamps ⇒ Object
Instance Method Details
#have_add_column(name, type = 'string') ⇒ Object Also known as: have_column
8 9 10 |
# File 'lib/migration-spec/matchers/content/have_column.rb', line 8 def have_add_column(name, type='string') have_call "t.#{type}", ":#{name}" end |
#have_change_column(name, type = 'string') ⇒ Object
24 25 26 |
# File 'lib/migration-spec/matchers/content/have_column.rb', line 24 def have_change_column(name, type='string') have_call "t.change", ":#{name}\s*,\s*:#{type}" end |
#have_columns(columns = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/migration-spec/matchers/content/have_column.rb', line 13 def have_columns(columns = {}) raise ArgumentError, "Columns must be passed as a :name => :type Hash" if !columns.kind_of? Hash col_hash = {} columns.each_pair do |name, type| method_call = "t.#{type}" arg = ":#{name}" col_hash[method_call] = arg end HaveCalls.new col_hash end |
#have_remove_column(name) ⇒ Object
4 5 6 |
# File 'lib/migration-spec/matchers/content/have_column.rb', line 4 def have_remove_column(name) have_call 't.remove', ":#{name}" end |
#have_timestamps ⇒ Object
28 29 30 |
# File 'lib/migration-spec/matchers/content/have_column.rb', line 28 def have_call "t.timestamps" end |