Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The definition in the blog post is shoulda specific (the setup(&amp;block) method is defined in the module Thoughtbot::Shoulda in context.rb. shoulda.rb then has TestCase extend that module).</p> <p>The definition for pure test::unit is </p> <pre><code># File test/unit/testcase.rb, line 100 def setup end </code></pre> <p>what you could do is </p> <pre><code>def setup log_test end private def log_test if Rails::logger # When I run tests in rake or autotest I see the same log message multiple times per test for some reason. # This guard prevents that. unless @already_logged_this_test Rails::logger.info "\n\nStarting #{@method_name}\n#{'-' * (9 + @method_name.length)}\n" end @already_logged_this_test = true end </code></pre> <hr> <p>edit </p> <p>if you really don't want to edit your files you can risk reopenning test case and extend run instead :</p> <pre><code>class Test::Unit::TestCase alias :old_run :run def run log_test old_run end end </code></pre> <p>this should work (I don't have ruby around to test though)</p> <hr> <p>I give up ! (in frustration)</p> <p>I checked the code and rails actually does magic behind the scene which is probably why redefining run doesn't work. </p> <p>The thing is : part of the magic is including ActiveSupport::CallBack and creating callbacks for setup and teardown. </p> <p>which means </p> <pre><code>class Test::Unit::TestCase setup :log_test private def log_test if Rails::logger # When I run tests in rake or autotest I see the same log message multiple times per test for some reason. # This guard prevents that. unless @already_logged_this_test Rails::logger.info "\n\nStarting #{@method_name}\n#{'-' * (9 + @method_name.length)}\n" end @already_logged_this_test = true end end end </code></pre> <p>should definitely work</p> <p>and actually running tests with it does work. where I am confused is that this is the first thing I tried and it failed with the same error you got</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload