Sha256: a3fcd88e1de82491641e1fe346c8f46a2e75049db760971098478528f3984ba0

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'test/unit'
require 'contacts_g'

Dir.mkdir("gdbm_contacts") unless File.exist?("gdbm_contacts")

class GDBMTest < Test::Unit::TestCase
  
  def setup
    @list = ContactList.new("gdbm_contacts")
    @contact = Contact.new("Joe Smith")
    
    @list << @contact
    
    @contact.home["street1"] = "123 Main Street"
    @contact.home["city"] = "Somewhere"
    @contact.work["phone"] = "(000) 123-4567"
    @contact.extras["instrument"] = "Cello"
    @contact.email = "joe@somewhere.abc"
  end
  
  def teardown
    @list.delete("Joe Smith") if @list["Joe Smith"]
  end

  def test_retrieving_a_contact_from_list
    contact = @list["Joe Smith"]
    assert_equal("Joe Smith", contact.name)
  end
  
  def test_delete_a_contact_from_list
    assert(!@list.empty?)
    @list.delete("Joe Smith")
    assert(@list.empty?)
    assert(@list.contact_cache.empty?)
  end
  
  def test_home
    contact = @list["Joe Smith"]
    assert_equal("123 Main Street", contact.home["street1"])
  end
  
  def test_email
    contact = @list["Joe Smith"]
    assert_equal("joe@somewhere.abc", contact.email)
  end
  
  def test_non_existent_contact_is_nil
    assert_equal(nil, @list["Some Person"])
  end
  
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
wbzyl-datamapper-tutorial-0.0.10 lib/public/doc/plain-text-files/contacts_g_test.rb
wbzyl-datamapper-tutorial-0.0.11 lib/public/doc/plain-text-files/contacts_g_test.rb
wbzyl-datamapper-tutorial-0.0.9 lib/public/doc/plain-text-files/contacts_g_test.rb
nosql-tutorial-0.1.1 lib/public/doc/plain-text-files/contacts_g_test.rb
nosql-tutorial-0.1.0 lib/public/doc/plain-text-files/contacts_g_test.rb