Hi all
I am messing around with RESTful controller using edge rails (revision
5222) and am having the following problem. I have changed the function
that is failing by adding the client name in the flasg but that it is
and I haven''t changed the test code either but I am getting this error.
The fact that "Expected" is empty makes me wonder if it is a bug in
edge
rails?
---Failure message---
1) Failure:
test_should_create_client(ClientsControllerTest)
[./test/functional/clients_controller_test.rb:30]:
<3> expected but was
<2>.
---Controller code---
def create
@client = Client.new(params[:client])
respond_to do |format|
if @client.save
flash[:notice] = @client.name + '' was successfully
created.''
format.html { redirect_to clients_url }
format.xml do
headers["Location"] = client_url(@client)
render :nothing => true, :status => "201 Created"
end
else
format.html { render :action => "new" }
format.xml { render :xml => @client.errors.to_xml }
end
end
end
---Test code---
def test_should_create_client
old_count = Client.count
post :create, :client => { }
assert_equal old_count+1, Client.count
assert_redirected_to client_path(assigns(:client))
end
Any help would be much appreciated because the perfectionist in me
refuses to commit and continue until all the tests are passing :)
RJ
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
RJ wrote:> Hi all > > I am messing around with RESTful controller using edge rails (revision > 5222) and am having the following problem. I have changed the function > that is failing by adding the client name in the flasg but that it is > and I haven''t changed the test code either but I am getting this error. > The fact that "Expected" is empty makes me wonder if it is a bug in edge > rails?Its not empty, it''s 3 :) If you take out the assert_equal, does the assert_redirectd_to work ? A> -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Alan C Francis wrote:> RJ wrote: >> Hi all >> >> I am messing around with RESTful controller using edge rails (revision >> 5222) and am having the following problem. I have changed the function >> that is failing by adding the client name in the flasg but that it is >> and I haven''t changed the test code either but I am getting this error. >> The fact that "Expected" is empty makes me wonder if it is a bug in edge >> rails? > > Its not empty, it''s 3 :) > > If you take out the assert_equal, does the assert_redirectd_to work ? > > A>Aaaah I thought that was some sort of line numbering. I thought the messages were "Expected FOO but was BAR". Not "FOO expected but was BAR".. Crawls back into the corner. Ok, so why isn''t it registering the new client ;) Thanks RJ -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
RJ wrote:> Aaaah I thought that was some sort of line numbering. I thought the > messages were "Expected FOO but was BAR". Not "FOO expected but was > BAR".. > > Crawls back into the corner. > > Ok, so why isn''t it registering the new client ;)If you comment out the assert_equal, and let the assert_redirected_to have a go, you''ll be able to see if the controller method succeeds. I think there must also be a way to assert the contents of the flash, which you can try as long as you comment out the assert_equal(which stops the test in its tracks) Alan -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
>> Ok, so why isn''t it registering the new client ;) > > If you comment out the assert_equal, and let the assert_redirected_to > have a go, you''ll be able to see if the controller method succeeds. > > I think there must also be a way to assert the contents of the flash, > which you can try as long as you comment out the assert_equal(which > stops the test in its tracks) > > AlanWhoops, that was me thinking to myself with my fingers, wasn''t actually looking for an answer ;) But thanks regardless. RJ -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---