Sha256: 4900c4a464d9c88286f015d3dd396968af7dc5aaaca330e1c1480b61d96c2a91

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

require 'test_helper'

ActiveRecord::Schema.define do
  create_table :messages, :force => true do |t|
    t.string :title
    t.string :description
  end
end

class Message < ActiveRecord::Base
  validates_decency_of :title, :description
end

class TestValidatesDecencyOf < Test::Unit::TestCase
  def setup
    @decent = Message.new :title => 'Hello world', :description => 'I am clean'
    @indecent = Message.new :title => 'Hello f*u*c*k*i*n*g world', :description => 'I am ~-S-h-I-t-T-y-~'
  end

  def test_should_not_die_on_empty_strings
    @decent.description = nil
    assert @decent.valid?
  end
  
  def test_should_allow_decent_strings
    assert @decent.valid?
  end
  
  def test_should_disallow_indecent_strings
    assert_equal false, @indecent.valid?
    assert @indecent.errors.on(:title)
    assert @indecent.errors.on(:description)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_decency_of-1.5.0 test/test_validates_decency_of.rb