framauro13
framauro13

Reputation: 797

ActiveSupport TestCase not running in Sinatra

I'm setting up a new Sinatra app and am having issues getting my tests to run via a rake task. When I run rake:test, the task runs, shows me which files it will be running, but nothing happens. I know it's loading the class because it has failed due to syntax errors, but I never see my tests running. What am I missing? Below is my configuration and example test:

rakefile.rb

require "rake/testtask"
require "sinatra/activerecord/rake"
require "./app"

task :default => :test

TEST_FILES = FileList["test/**/test*.rb"]

desc "Run all of the tests for redFish"
Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = TEST_FILES
  t.verbose = true
end

task :default => "test"

test/test_helper.rb

ENV["RACK_ENV"] = "test"

require "rack/test"
require "awesome_print"
require "active_support"
require "active_support/core_ext"

/test/unit/test_organization.rb

require File.expand_path '../../test_helper.rb',__FILE__

class TestOrganization < ActiveSupport::TestCase
  def setup
    puts "setup for tests"
  end

  test "validates_required_fields" do
    puts "RUNNING TESTS"
    assert true
    refute false
  end
end

When I run rake:test, I can see that test_helper and test_organization.rb are being found by the TestTask, but I don't see any tests pass/fail.

Am I missing something obvious?

Upvotes: 0

Views: 216

Answers (1)

framauro13
framauro13

Reputation: 797

Looks like the issue was caused by not requiring minitest/autorun in my test helper. I added that line, and the tests ran fine.

Upvotes: 1

Related Questions