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