Ruby on Rails Saturday, July 30, 2011

On 30 July 2011 12:45, Norbert Melzer <timmelzer@googlemail.com> wrote:
> This was originaly posted on stackoverflow
> (<http://stackoverflow.com/questions/6848011/capybara-does-not-find-the-text-that-is-actually-there>)
>
> It would be nice if answers could be there to, if not I will summarize
> the helping answers and post them there.
>
> ---8<--- SO Post beginns here:
>
> In my actual project I use the following gems for testing:
>
> * capybara from git://github.com/jnicklas/capybara.git in revision
> 6641fddcfc337a3ddaa84ac59272e884090332c3
> * rails (3.1.0.rc5) (and its requirements)
> * factory_girl (2.0.1)
> * factory_girl_rails (1.1.0)
> * rspec (2.6.0)
> * rspec-core (2.6.4)
> * rspec-rails (2.6.1)
>
> When doing `rake spec` I get the following error:
>
>    ...F.....*................*....*.*.*.
>
>    Pending:
>      <pending snipped out>
>
>    Failures:
>
>      1) Articles GET /articles/:id should show the article when clicking it
>         Failure/Error: page.should have_content a.body
>           expected there to be content "Dieser Artikel ist nur zum
> testen, erfüllt keinen Sinn und langweilig ist mir ohnehin. Das sollte
> nur mal so gesagt werden... MfG Euer Admin!\n" in "Stars3\n  \n
> Stars!Artikel - 1 - This is an article created just for testing
> purpose\n  \n  \n    Artikel\n\n    \nDieser Artikel ist nur zum
> testen, erfüllt keinen Sinn und langweilig ist mir ohnehin. Das sollte
> nur mal so gesagt werden... MfG Euer Admin!\n\n  \n"
>         # ./spec/requests/articles_spec.rb:46
>
>    Finished in 1.96 seconds
>    37 examples, 1 failure, 5 pending
>
>    Failed examples:
>
>    rspec ./spec/requests/articles_spec.rb:40 # Articles GET
> /articles/:id should show the article when clicking it
>
> I cant see any differences between the expectation and the result...
> Can you point me in the right direction to make this one work?

I suspect the problem may be around the newlines and whitespace. Are
you sure they match exactly? Try first changing the test and factory
to provide a simple string and work up from there. Do you really need
such a complex example text anyway? If yes then use a regular
expression and ignore the whitespace details.

Colin

--
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@googlegroups.com.
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.

No comments:

Post a Comment