Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

assert_no_template

I was wondering if do we have something like assert_no_template as the opposite of the assert_template.

What I'm trying to test is that a concrete template is not used in the actual render.

like image 588
fguillen Avatar asked Feb 11 '11 15:02

fguillen


2 Answers

A better way would be to use the :count argument to assert_template:

assert_template :partial => 'YOUR_PARTIAL', :count => 0
like image 199
ChrisW Avatar answered Nov 06 '22 22:11

ChrisW


I put this in my test_helper.rb:

  def assert_template_not_used(template, msg = nil)
    assert [email protected]? {|t, num| t.match(template)}, msg
  end
like image 23
Rachel Shallit Avatar answered Nov 07 '22 00:11

Rachel Shallit