Return to Snippet

Revision: 1162
at September 20, 2006 03:43 by Catfish


Initial Code
#require 'test/unit' unless defined? $ZENTEST and $ZENTEST

require File.dirname(__FILE__) + '/../test_helper'

class AddressObserverTest < Test::Rails::TestCase
  def test_class_instance
    assert 1
  end
end

class AddressTest < Test::Rails::TestCase

  include ARTestHelper

  check_associations %w(account addressable)

  check_validations_for :street_address do
    invalid nil
    invalid 'st'
    invalid 'st'.ljust(200)
    valid 'This is some street address'
  end  
  
  check_validations_for :city do
    invalid nil
    invalid 'ci'
    invalid 'ci'.ljust(200)
    valid 'Funchal'
  end  
  
  check_validations_for :state do
    invalid nil
    invalid 's'
    invalid 's'.ljust(200)
    valid 'Madeira'
    valid 'CA'
  end  
  
  check_validations_for :postal_code do
    invalid nil
    invalid 'p'
    invalid 'p'.ljust(200)
    valid '9000-055'
  end    
  
  def setup
    super
    @address = @rentacar_account.addresses.find(1)
    @a = @address
  end  

  def test_account
    assert_a_account_instance
  end

  def test_account_eh
    assert_raise( ArgumentError){ @address.account? }
  end

  def test_account_equals
    assert_equal @address.account, @rentacar_account
    @address.account = @property_account
    assert_equal @address.account, @property_account
  end

  def test_addressable
    assert_a_addressable_instance
  end

  def test_addressable_equals
    assert_equal @address.addressable, @rentacar_account.branches.find(1)
    new_addressable = valid_branch( :parent => @rentacar_account )
    @address.addressable = new_addressable
    assert_equal @address.addressable, new_addressable
  end

  def test_build_account
    assert_a_account_build
  end

  def test_create_account
    assert_a_account_create
  end

  def test_has_account_eh
    assert @address.has_account?
  end

  def test_set_account_target
    assert_a_account_target
  end

  def test_set_addressable_target
    assert_a_addressable_target
  end
  
  def test_build_country
    assert_instance_of Globalize::Country, @address.build_country
  end

  def test_country
    assert_a_country_instance
  end

  def test_country_eh
    assert_raise( ArgumentError ){@address.country? }
  end

  def test_country_equals
    @address.country = Globalize::Country.find(:first)
    assert_equal Globalize::Country.find(:first), @address.country
  end

  def test_create_country
    assert_a_country_create
  end

  def test_has_country_eh
    assert @address.has_country?
  end

  def test_set_country_target
    assert_a_country_target
  end  
  
end

Initial URL

                                

Initial Description

                                

Initial Title
ARTestHelper example

Initial Tags

                                

Initial Language
Ruby