assert_valid in unit tests after upgrade to rails 2.3 doesn't work
247 views
Skip to first unread message
Constantin Gavrilescu
unread,
Apr 7, 2009, 2:34:58 AM4/7/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk, co...@apluscompuservices.com
def test_valid
assert_valid State.first
end
Error:
test_valid(StateTest):
NoMethodError: undefined method `assert_valid' for #<StateTest:
0x7f0d60750318>
I see that test_valid is now in
ActionController::Assertions::ModelAssertions. Does this mean that
test_valid is designed to be used i ActionController tests only?
I can change my assert_valid(State.first) into assert
(State.first.valid?) but assert_valid prints meaninful failure
messages, unlike assert which just tells me "nil is not true". How can
I use assert_valid in my unit tests? My test classes declared
something like this: class StateTest < ActiveSupport::TestCase
Mohamed Aslam
unread,
Apr 14, 2009, 8:17:35 AM4/14/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
Having the same problem here. But still didn't find any solution.
On Apr 7, 11:34 am, Constantin Gavrilescu
Tonypm
unread,
May 29, 2009, 9:52:26 AM5/29/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
hi,
just upgrading to 2.3.2 and getting same, did you resolve this at all?
Tonypm
Tonypm
unread,
May 29, 2009, 10:40:35 AM5/29/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
I didnt want to go change all my tests just at the moment, so putting
assert_valid in my test_helper gets me over that for the moment. Bit
of a time waster, since I was going from 2.0.2 to 2.3 so had not seen
the dep error.
def assert_valid(record)
assert record.valid?, record.errors.full_messages.join("\n")
end