Rob Aldred
2010-Nov-30 12:10 UTC
[rspec-users] Testing html email content with have_selector rspec2 rails3 fails
Previously on rails 2.x I have been able to test the content of my html actionmailer emails. In rspec 1.x: @mailer = OrderMailer.create_receipt(@order) @mailer.body.should have_tag(''.order_number'') @mailer.body.should have_tag(''.billing_address'') @mailer.body.should have_tag(''.delivery_address'') I have changed to rspec 2.x style @mailer = OrderMailer.receipt(@order) @body = @mailer.encoded @body.should have_tag(''.order_number'') @body.should have_tag(''.billing_address'') @body.should have_tag(''.delivery_address'') It fails. I suspect theres something else that have_tag was doing that have_selector is not? Am I doing something wrong? Is there a better way to tests the content of my emails? Maybe I should never have tested email content this way, is it more a job for cucumber? Look forward to your responses. Thanks Rob
Andrew Premdas
2010-Dec-20 23:47 UTC
[rspec-users] Testing html email content with have_selector rspec2 rails3 fails
Rob, This doesn''t make sense 1. None of your examples here are using have_selector ! 2. Why is OrderMailer no longer creating a receipt 3. Why is @mailer being encoded Is mailer.body the same in both versions, can you show this. Have you tried using a debugger before the first have_tag line. All best Andrew :) On 30 November 2010 12:10, Rob Aldred <raldred at gmail.com> wrote:> Previously on rails 2.x > I have been able to test the content of my html actionmailer emails. > > In rspec 1.x: > > @mailer = OrderMailer.create_receipt(@order) > @mailer.body.should have_tag(''.order_number'') > @mailer.body.should have_tag(''.billing_address'') > @mailer.body.should have_tag(''.delivery_address'') > > I have changed to rspec 2.x style > > @mailer = OrderMailer.receipt(@order) > @body = @mailer.encoded > @body.should have_tag(''.order_number'') > @body.should have_tag(''.billing_address'') > @body.should have_tag(''.delivery_address'') > > It fails. > I suspect theres something else that have_tag was doing that > have_selector is not? > Am I doing something wrong? Is there a better way to tests the content > of my emails? > > Maybe I should never have tested email content this way, is it more a > job for cucumber? > Look forward to your responses. > > Thanks > Rob > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101220/2177a32a/attachment.html>