3
我想在我的RSpec測試中訪問燈具數據,但似乎沒有加載任何。RSpec 2似乎沒有加載任何燈具?
spec_helper.rb
config.fixture_path = "#{::Rails.root}/db/fixtures"
config.use_transactional_fixtures = true
config.global_fixtures = :all
這是我的燈具之一:
cash:
name: cash
interest: 1
term: <%= Time.now.to_s :db %>
現在測試創建了具有after_create回調用戶:
ft = FundType.find_by_name("cash")
Fund.create(fund_type_id: ft.id, amount: 1000) <--- this is where the error occurs
錯誤:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id>
任何想法?
文件存在,配置完全一樣。這是'puts FundType.all' - >'[]'的輸出,所以沒有記錄。 – Cojones 2012-04-01 11:11:25
你可以嘗試刪除ERB?所以像這樣...術語:「2012-04-01」(也可以查看奇怪的間距或製表符,或者尾隨空格,或沒有讀取權限的文件) – joelparkerhenderson 2012-04-01 11:16:32
不可以,不會幫助... – Cojones 2012-04-01 11:30:11