Sha256: 9a86df4be02a9278afc5f0da93aefb7b4a059dc6002efa6ffb1c50018f973df1

Contents?: true

Size: 757 Bytes

Versions: 2

Compression:

Stored size: 757 Bytes

Contents

module RSpec::RubyContentMatchers    
  def have_remove_column(name)
    HaveCall.new('t.remove', ":#{name}")
  end

  def have_add_column(name, type='string')
    HaveCall.new("t.#{type}", ":#{name}")
  end
  alias_method :have_column, :have_add_column

  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

  def have_change_column(name, type='string')
    HaveCall.new("t.change", ":#{name}\s*,\s*:#{type}")
  end

  def have_timestamps
    HaveCall.new("t.timestamps")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
generator-spec-0.5.0 lib/generator_spec/matchers/migration/have_column.rb
generator-spec-0.4.8 lib/generator_spec/matchers/migration/have_column.rb