bundle exec rake test does nothing
Asked Answered
J

2

5

I am trying to get my heads "dirty" with TDD and for some reason when I run bundle exec rake test on the command line, nothing happens.

Here is my RakeFile:

require 'rake/testtask'

Rake::TestTask.new do |test|
  test.libs << 'test'
end

desc "Run Tests"
task :default => :test

Here is my test file:

require 'test/unit'

class TestMygem < Test::Unit::TestCase
  def test_silly_example
    assert_equal 2+2, 5
  end
end
Jaundiced answered 16/1, 2013 at 16:22 Comment(4)
Have you migrated the db? rake db:migrate ?Odeliaodelinda
There is nothing to migrate... this is a simple RubyGem I am working onJaundiced
Found it! I forgot to add test.test_files = FileList['tests/test_*.rb'] to my RakeFileJaundiced
It's best to add an answer with that if it solved your problem.Kolo
J
9

I forgot to add this line to my RakeFile

test.test_files = FileList['tests/test_*.rb']

So, all in all, here is my final RakeFile

require 'rake/testtask'

Rake::TestTask.new(:test) do |test|
  test.libs << 'test'
  test.test_files = FileList['tests/test_*.rb']
end

desc "Run Tests"
task :default => :test
Jaundiced answered 16/1, 2013 at 16:29 Comment(0)
M
2

As of Rails 3.2.20, the following is acceptable

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
  t.libs << 'test'
  t.pattern = 'test/_test*.rb'
  t.verbose = false # or true
end

desc "Run Tests"
task :default => :test
Maori answered 9/11, 2014 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.