Sha256: d7791687e0ca954419d0df55bf6d5c17cbb25b816e3647c9b65989e9ceea91ff
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require '../helper' require '../model/user' class CreateObjectTest < Test::Unit::TestCase def setup @attributes = {:name=>'aaron',:email=>'aaron@nonobo.com',:password=>'123456'} end def test_new_object @u = User.new assert_equal true,@u.new_record? User.attributes.each do |attribute| assert_equal true,@u.respond_to?(attribute) end end def test_new_object_with_attributes @u = User.new(@attributes) User.attributes.each do |attribute| assert_equal @attributes[attribute],@u.send(attribute) end end def test_create_object @u = User.create(@attributes) assert_equal false,@u.new_record? @u.destroy end def test_find_object User.create(@attributes) @u = User.find(@attributes[:email]) User.attributes.each do |attribute| assert_equal @attributes[attribute],@u.send(attribute) end assert_equal false,@u.new_record? end def test_delete_object User.create(@attributes) User.delete(@attributes[:email]) assert_raise AntMapper::ObjectNotFound do User.find(@attributes[:email]) end end def test_create_multiple_object @objects = [{:name=>'aaron',:email=>'aaron@nonobo.com'},{:name=>'yalong',:email=>'yalong@nonobo.com'}] User.create(@objects) @objects.each do |object| @u = User.find(object[:email]) assert_equal object[:email],@u.email @u.destroy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ant-mapper-0.0.2 | ./spec/case/create_object_test.rb |