Let me clarify:

The moment you add any validations to a scaffold model the functional tests
start to fail.

I currently use this solution:

class CommentsControllerTest < ActionController::TestCase
  def comment
    { :body => 'Hello!', :email => '[email protected]', :name =>
'CmdJohnson' }
  end

  def test_should_create_comment
    assert_difference('Comment.count') do
      post :create, :comment => comment
    end

    assert_redirected_to comment_path(assigns(:comment))
  end

# Further tests here ..
end

Possible solutions include:
1. Keep a hash 'role model' that is always valid and must be changed with
model validations
2. Convert an existing object to a Hash that can be passed to the 'get'
method.

On Thu, Apr 23, 2009 at 4:27 PM, Commander Johnson <
[email protected]> wrote:

> Hi,
>
> In a Rails functional test, you can say this:
>
> post :create, :post => { :body => 'This is my post.', :title => 'Welcome to
> my post' }
>
> This works until you change the Post class' validation properties. Is there
> a way to convert an object (that happens to be already valid) to the hash
> form required by the functional test?
>
> CmdJohnson
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to