4
When I run all the tests or just tests a file is working normally, but when I try to run just one test, it just doesn’t run.
I have this test
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "is ban" do
user = build(:user, role: :ban)
assert user.banned?
end
end
However when I run on the console just this file, I have the answer expected in the tests
rake test/models/user_test.Rb
Run options: -Seed 34310
Running tests:
.
Finished tests in 0.041871s, 23.8831 tests/s, 23.8831 assertions/s.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
But when I want to run only one function in the same way as the Rails documentation explains. ( http://guides.rubyonrails.org/testing.html#running-tests )
rake test/models/user_test.Rb is_ban
Run options: -n is_ban --Seed 27215
Running tests:
Finished tests in 0.007734s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
I don’t have the test is_ban run, could someone explain to me how I can run just one specific test? I’ve tried to do it many ways and I haven’t succeeded.
I am using Rails 4.0.2, Ruby 2.0 and I have some test Gem installed as factory_girl, mocha and Shoulda.
Try
rake test test/models/user_test.rb test_is_ban
, as the documentation says. Note thetest_
in front.– Guilherme Bernal
@William had not paid attention to that detail, but I think that was not so clear in the documentation. thank you very much.
– Felipe Bergamo