How to run a single test in Ruby on Rails 3.0.7 using Unit :: Test?

Yes, I know that the same question was asked (http://stackoverflow.com/questions/1506780/how-to-run-single-test-from-rails-test-suite), but the solution does not seem to work for Rails 3. Maybe it works for Rails 2?

How to run a single test in Rails 3.0.7 using Unit :: Test? Not one test file, but a single test .

test "the truth" do assert false end 

ruby -I test test/functional/test_file.rb -n "the truth" generates 0 tests, 0 assertions, 0 failures, 0 errors

+6
source share
4 answers

Try regular expressions

 bundle exec ruby -I test test/functional/test_file.rb -n "/truth/" 
+6
source

The ruby ​​-I (...) -n "method only works for me in Rails 3 as follows:

 bundle exec ruby -I test test/functional/test_file.rb -n "the truth" 

But then again, I use jRuby, so YMMV

+3
source
+2
source

For some odd reason, you should put underscores instead of spaces in the test string, and then use a regular expression. So this works for me:

 bundle exec ruby -I test test/functional/test_file.rb -n "/the_truth/" 
+2
source

Source: https://habr.com/ru/post/903520/


All Articles