[rspec-users] Newlines breaking "should have_tag :text =>" specs

Chris Hoffman chris.c.hoffman at gmail.com
Fri Apr 27 12:13:50 EDT 2007


You could do the following:

:text => /\s*#{product.name}\s*/

which would ignore arbitrary amounts of whitespace.

-Chris

On 4/27/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Hi
>
> I've got an RJS spec that is failing.  It looks like this:
>
> specify "should have list of prooducts for particular provider" do
>    @provider.products.each do |product|
>        response.should have_tag("#product_name_#{product.id}", :text
> => "#{product.name}")
>    end
> end
>
> It fails when it renders a partial containing this:
>
>              <td id="product_name_<%= product.id%>">
>                  <%= product.name %>
>              </td>
>
> and gives this error:
>
> 'A rendered show_provider_products_for_dealer view should have list
> of prooducts for particular provider' FAILED
> <"product 1"> expected but was
> <"\\r\n                product 1\\r">.
> <false> is not true.
>
>
> The following change makes it work:
>
>              <td id="product_name_<%= product.id%>"><%= product.name %
>  ></td>
>
>
> Bizarrely, while it fails on my Mac, it passes on Windows (both
> running 0.8.2).  Also it doesn't appear to affect RHTML specs, just RJS.
>
> Any ideas?
>
> Thanks
> Ashley
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list