Ashley Moran
2007-Apr-27 16:07 UTC
[rspec-users] Newlines breaking "should have_tag :text =>" specs
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
Chris Hoffman
2007-Apr-27 16:13 UTC
[rspec-users] Newlines breaking "should have_tag :text =>" specs
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 >
Ashley Moran
2007-Apr-27 16:30 UTC
[rspec-users] Newlines breaking "should have_tag :text =>" specs
On 27 Apr 2007, at 17:13, Chris Hoffman wrote:> You could do the following: > > :text => /\s*#{product.name}\s*/ > > which would ignore arbitrary amounts of whitespace. > > -ChrisCool thanks - I''ll try that over the weekend. In the mean time, any idea why it passes on Windows and not OS X? Seems very wierd.