Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
assert_valid in unit tests after upgrade to rails 2.3 doesn't work
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Constantin Gavrilescu  
View profile  
 More options Apr 7 2009, 2:34 am
From: Constantin Gavrilescu <comisarulmoldo...@gmail.com>
Date: Mon, 6 Apr 2009 23:34:58 -0700 (PDT)
Local: Tues, Apr 7 2009 2:34 am
Subject: assert_valid in unit tests after upgrade to rails 2.3 doesn't work
  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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mohamed Aslam  
View profile  
 More options Apr 14 2009, 8:17 am
From: Mohamed Aslam <aslamnaj...@gmail.com>
Date: Tue, 14 Apr 2009 05:17:35 -0700 (PDT)
Local: Tues, Apr 14 2009 8:17 am
Subject: Re: assert_valid in unit tests after upgrade to rails 2.3 doesn't work
Having the same problem here. But still didn't find any solution.

On Apr 7, 11:34 am, Constantin Gavrilescu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tonypm  
View profile  
 More options May 29 2009, 9:52 am
From: Tonypm <tonypmar...@hotmail.com>
Date: Fri, 29 May 2009 06:52:26 -0700 (PDT)
Local: Fri, May 29 2009 9:52 am
Subject: Re: assert_valid in unit tests after upgrade to rails 2.3 doesn't work
hi,

just upgrading to 2.3.2 and getting same, did you resolve this at all?

Tonypm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tonypm  
View profile  
 More options May 29 2009, 10:40 am
From: Tonypm <tonypmar...@hotmail.com>
Date: Fri, 29 May 2009 07:40:35 -0700 (PDT)
Local: Fri, May 29 2009 10:40 am
Subject: Re: assert_valid in unit tests after upgrade to rails 2.3 doesn't work
Ok, so

Rails Guide http://guides.rubyonrails.org/testing.html
para 3.5 says it exists - I guess the guide needs amending?

It was deprecated at 2.2.2
 - "assert_valid is deprecated. Use assert record.valid? instead"
see
http://github.com/rails/rails/commit/d4754677a34d34d4a0955a04f2cc6571...
and
https://rails.lighthouseapp.com/projects/8994/tickets/1470-assert_val...

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

Tonypm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »