How to write rspec for: @community = Community.new(params[:community]) @community.url_title = params[:community][:title].parameterize I searched for it for long but didnt get any positive result. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You need to provide a bit more detail in order to help here. Basically what you want to do, I believe, is to test when you call the method that encloses that code, it sets the @community.url_title with parameterize you''ll need to pass the params over to the method and test that at the end of the method call, @community.url_title has the expected result. If you provide more context, I could show you an example. Luis http://www.saffie.ca -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanx luis to take interest in my query. The above code is in my communities_controller. Its inside the create action. I want to pass the title of the called community in the url. Before passing it to the database i m converting title as an url by using parameterize method. I wrote a test case for it as follows: Community.stub(:new).with({''these'' => ''params''}) { mock_community(:save => true) } post :create, :community => {''these'' => ''params''} assigns(:community).should be(mock_community) But it gives the following failure: Failure/Error: post :create, :community => {''these'' => ''params''} undefined method `parameterize'' for nil:NilClass So help me in writing test case for it. Ishit -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.