2015-02-12 102 views
0

我不知道爲什麼這不起作用。我使用「rails g test_unit:model」在Rails 4.2.0應用程序中生成了一個模型測試,而「rake test」什麼都不做。爲什麼我的Rails 4.2.0測試不能運行?

$ rake test 

下面是測試的目錄結構/(我也有不知道爲什麼沒有產生test_helper.rb,我也不知道如何產生的呢。)

$ find test 
test 
test/models 
test/models/domain_test.rb 

我測試的內容:

$ more test/models/domain_test.rb 
require 'test_helper' 

class DomainTest < ActiveSupport::TestCase 

    test "URL gets transformed into domain" do 
    domain = Domain.create("http://google.com/") 
    expected = "google.com" 
    assert expected, domain.name, "domain name could not be extracted from URL" 
    end 

end 

我的Rakefile:

$ more Rakefile 
# Add your own tasks in files placed in lib/tasks ending in .rake, 
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 

require File.expand_path('../config/application', __FILE__) 

Rails.application.load_tasks 

回答

0

想通了......新的Rails 4.2.0應用程序有# require "rails/test_unit/railtie" 註釋掉了config/application.rb。我取消了評論,並從舊項目中複製了test_helper.rb,現在測試運行。

相關問題