2016-01-25 57 views
1

環境:開拓者和MINITEST - NameError:未初始化不斷MINITEST

rails -v 
Rails 4.2.5 

ruby -v 
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux-gnu] 

bundle list trailblazer 
trailblazer-1.1.0 

我的工作,通過在開拓者書的例子,我遇到了,我不明白的情況。按照書中給出的設置,當我使用bundle rake test/concerns/ar_invoice/crud_test.rb運行特定測試時,它按預期運行。但是,如果我只需運行bundle rake test然後我看到這個:

bundle rake test 
rake aborted! 
NameError: uninitialized constant MiniTest 
./test/concepts/ar_invoice/crud_test.rb:1:in `<top (required)>' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define' 
./bundle /lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:114:in `each' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:113:in `each' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:113:in `block in define' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task' 
./bundle/lib/gems/railties-4.2.5/lib/rails/test_unit/testing.rake:8:in `block in <top (required)>' 
Tasks: TOP => test:run 
(See full trace by running task with --trace) 

文件crud_test.rb包含此:

cat test/concepts/ar_invoice/crud_test.rb 

class ARInvoiceCrudTest < MiniTest::Spec 
    describe("Create") do 
    it("persists valid") do 
     ar_invoice = ARInvoice::Create.(
     :ar_invoice => { :invoice_number => 101, 
         :client_number => 1234 
     } 
    ).model 

     ar_invoice.persisted?.must_equal(true) 
     ar_invoice.invoice_number.must_equal(102) 
     ar_invoice.client_number.must_equal(5678) 
    end 
    end 
end 

而且。測試/ test_helper.rb中看起來是這樣的:

cat test/test_helper.rb 

ENV['RAILS_ENV'] ||= 'test' 
require File.expand_path('../../config/environment', __FILE__) 

require 'rails/test_help' 
require 'minitest/spec' 
require "minitest/autorun" 

require "trailblazer/rails/test/integration" 

env | grep RAILS_ENV不產生輸出。

我還缺少什麼設置?不應該運行bundle rake test只需拾取crud_test.rb文件,並在文件在命令行上顯式命名時以相同的方式運行測試?

回答

1

這就是答案:

和當然,每個測試文件的頂部添加require 'test_helper'

相關問題