On 21.11.2011 20:24, Greg wrote:> Hi all,
> I got some problems with my integration test. I have a form were a new
> user can sign up. If the form is blank and submitted the normal error
> occur. The error div has an id "error_explanation". In my
integration
> test i try to match it but the test is always red. Here some Code:
>
> # encoding : utf-8
> require ''spec_helper''
>
> describe "Users" do
>
> describe "signup" do
> describe "failure" do
>
> it "should not make a new user" do
> lambda do
> visit registrieren_path
> fill_in "Benutzername", :with => ""
> fill_in "Email", :with => ""
> fill_in "Passwort", :with => ""
> fill_in "Passwort bestätigen", :with => ""
> click_button
> response.should render_template(''users/new'')
> response.should have_selector("div", :id =>
> "error_explanation")
> end.should_not change(User, :count)
> end
> end
> end
> end
>
>
> Here is the error:
>
> expected following output to contain a <div
id=''error_explanation''/> tag
> ...
> and the whole html output.
>
>
> I checked my output and the strange thing is that i even can''t
find
> the form in the output. It looks like the test is checking the index
> page instead of the one tried to reach with the visit registrieren_path.
>
> I''m using Rspec Rails v.2.7.0 with Webrat 0.7.3
>
> Hope someone got a hint for me :)
>
> Best regards
>
> Greg
>
Ok I found the error. I should have pass the submit buttons value to the
click_button function. Now the test is green :)
Thanks anyway.
Regards Greg
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.