Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following answer is based on: <a href="https://stackoverflow.com/q/1506780/664833">How to run single test from rails test suite?</a> (stackoverflow)</p> <p>But very briefly, here's the answer:</p> <pre><code>ruby -I test test/functional/whatevertest.rb </code></pre> <p>For a <em>specific</em> <code>functional</code> test, run:</p> <pre><code>ruby -I test test/functional/whatevertest.rb -n test_should_get_index </code></pre> <p>Just put underscores in places of spaces in test names (as above), or quote the title as follows:</p> <pre><code>ruby -I test test/functional/whatevertest.rb -n 'test should get index' </code></pre> <p>Note that for <code>unit</code> tests just replace <code>functional</code> with <code>unit</code> in the examples above. And if you're using <strong>bundler</strong> to manage your application's gem dependencies, you'll have to execute the tests with <code>bundle exec</code> as follows:</p> <pre><code>bundle exec ruby -I test test/unit/specific_model_test.rb bundle exec ruby -I test test/unit/specific_model_test.rb -n test_divide_by_zero bundle exec ruby -I test test/unit/specific_model_test.rb -n 'test divide by zero' </code></pre> <p><strong>Most importantly</strong>, note that the argument to the <code>-n</code> switch is <em>the name of the test, and the word "test" prepended to it</em>, with spaces or underscores depending on whether you're quoting the name or not. The reason is that <code>test</code> is a convenience method. The following two methods are <em>equivalent</em>:</p> <pre><code>test "should get high" do assert true end def test_should_get_high assert true end </code></pre> <p>...and can be executed as <em>either</em> of the following (they are <em>equivalent</em>):</p> <pre><code>bundle exec ruby -I test test/integration/misc_test.rb -n 'test should get high' bundle exec ruby -I test test/integration/misc_test.rb -n test_should_get_high </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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