Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Yes I know the same question has been asked (How to run a single test from a rails test suite?), but the solution doesn't 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 a single 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

like image 382
B Seven Avatar asked Dec 10 '11 15:12

B Seven


2 Answers

Try Regular Expressions

bundle exec ruby -I test test/functional/test_file.rb -n "/truth/"
like image 96
Vikrant Chaudhary Avatar answered Sep 21 '22 01:09

Vikrant Chaudhary


The "ruby -I (...) -n" method only works for me in Rails 3 like this:

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

But then again, I'm using jRuby so YMMV

like image 32
ffoeg Avatar answered Sep 21 '22 01:09

ffoeg