Sha256: f00d24a9cf5b0aedee2c28046d2a24e3d08c19847b559365b65af8a54f233510

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

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

class TestClassyInheritance < Test::Unit::TestCase

  def setup
    User.depends_on :profile, :attrs => [:first_name, :last_name, :email]
    @user = User.new
  end
  
  def test_active_record_should_respond_to_depends_on
    assert ActiveRecord::Base.respond_to?(:depends_on)
  end
  
  def test_user_should_respond_to_find_with_profile
    assert User.respond_to?(:find_with_profile)
  end

  def test_user_should_respond_to_first_name
    assert @user.respond_to?(:first_name)
  end
  
  def test_user_should_respond_to_first_name=
    assert @user.respond_to?(:first_name=)
  end
  
  def test_user_should_respond_to_last_name
    assert @user.respond_to?(:last_name)
  end
  
  def test_user_should_respond_to_last_name=
    assert @user.respond_to?(:last_name=)
  end
  
  def test_user_should_respond_to_email
    assert @user.respond_to?(:email)
  end
  
  def test_user_should_respond_to_email=
    assert @user.respond_to?(:email=)
  end
  
  def test_user_should_be_invalid_without_profile_attributes
    @user.login = 'joe'
    assert !@user.valid?
  end
  
  def test_user_should_valid_with_profile_attributes
    @user.login = 'joe'
    @user.first_name = 'joe'
    @user.last_name = 'bloggs'
    @user.email = 'joe@bloggs.co.uk'
    
    assert @user.valid?
  end

  def test_user_should_have_nice_error_message
    @user = User.new(:first_name => "andy")
    @user.valid?

    assert @user.errors.full_messages.include?("Last name can't be blank")
    assert @user.errors.full_messages.include?("Email can't be blank")
    assert @user.errors.full_messages.include?("Login can't be blank")
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
johnsbrn-classy-inheritance-0.6.8.1 test/test_classy-inheritance.rb
johnsbrn-classy-inheritance-0.6.8.3 test/test_classy-inheritance.rb
johnsbrn-classy-inheritance-0.6.8.2 test/test_classy-inheritance.rb
classy-inheritance-0.7.0 test/test_classy-inheritance.rb