module SpecAssist

Constants

LORUM

Public Instance Methods

check_max_length(fields, length) click to toggle source
# File lib/spec_assist.rb, line 24
def check_max_length(fields, length)
  fields.each do |method|
    it "should require #{method} to be #{length.to_s} chars or less." do
      max = length.to_i + 1
      @obj.send( method.to_s + '=', get_string(max) )

      @obj.should_not be_valid
    end
  end
end
check_min_length(fields, length) click to toggle source
# File lib/spec_assist.rb, line 13
def check_min_length(fields, length)
  fields.each do |method|
    it "should require #{method} to be at least #{length.to_s} chars." do
      min = length.to_i - 1
      @obj.send( method.to_s + '=', get_string(min) )

      @obj.should_not be_valid
    end
  end
end
check_nullness(fields) click to toggle source
# File lib/spec_assist.rb, line 4
def check_nullness(fields)
  fields.each do |method|
    it "should not allow #{method} to be nil" do
      @obj.send( method.to_s + '=', nil )
      @obj.should_not be_valid
    end
  end
end
check_unique_field(a, b, field) click to toggle source
# File lib/spec_assist.rb, line 35
def check_unique_field(a, b, field)
  b.send( field.to_s + '=', a.send( field ) )
  b.should_not be_valid
end
get_string(length=255) click to toggle source
# File lib/spec_assist.rb, line 40
def get_string(length=255)
  str = LORUM[0, length.to_i]
  return str
end
varchar100() click to toggle source
# File lib/spec_assist.rb, line 49
def varchar100
  return get_string(103)
end
varchar255() click to toggle source
# File lib/spec_assist.rb, line 53
def varchar255
  return get_string(260)
end
varchar32() click to toggle source
# File lib/spec_assist.rb, line 45
def varchar32
  return get_string(33)
end