public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
Added assert_save and assert_valid to shoulda

git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@180 
7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
tsaleh (author)
Tue Aug 21 14:13:40 -0700 2007
commit  e579513034afbbb953a87a90388f3bff115dcc83
tree    b2f1943d1193645880d1858839389257021d5970
parent  7b3ca52efc8a0f16e59851780c95ccc5acb93b12
...
80
81
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
84
85
...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
@@ -80,6 +80,21 @@ module ThoughtBot # :nodoc:
0
         else assert(!collection.include?(x), msg)
0
         end
0
       end
0
+
0
+ # Asserts that the given object can be saved
0
+ #
0
+ # assert_save User.new(params)
0
+ def assert_save(obj)
0
+ assert obj.save, "Errors: #{obj.errors.full_messages.join('; ')}"
0
+ obj.reload
0
+ end
0
+
0
+ # Asserts that the given object is valid
0
+ #
0
+ # assert_save User.new(params)
0
+ def assert_valid(obj)
0
+ assert obj.valid?, "Errors: #{obj.errors.full_messages.join('; ')}"
0
+ end
0
     end
0
   end
0
 end

Comments

    No one has commented yet.