Ruby on rails 轨道测试用例夹具未加载
导轨似乎未加载任何用于单元或功能测试的夹具。我有一个简单的“products.yml”,它解析后看起来是正确的:Ruby on rails 轨道测试用例夹具未加载,ruby-on-rails,unit-testing,fixtures,Ruby On Rails,Unit Testing,Fixtures,导轨似乎未加载任何用于单元或功能测试的夹具。我有一个简单的“products.yml”,它解析后看起来是正确的: ruby: title: Programming Ruby 1.9 description: Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you
ruby:
title: Programming Ruby 1.9
description:
Ruby is the fastest growing and most exciting dynamic
language out there. If you need to get working programs
delivered fast, you should add Ruby to your toolbox.
price: 49.50
image_url: ruby.png
我的控制器功能测试从以下内容开始:
require 'test_helper'
class ProductsControllerTest < ActionController::TestCase
fixtures :products
setup do
@product = products(:one)
@update = {
:title => 'Lorem Ipsum' ,
:description => 'Wibbles are fun!' ,
:image_url => 'lorem.jpg' ,
:price => 19.95
}
end
我确实遇到了另一个Rails测试夹具问题,但这导致了一个插件问题(与加载夹具的顺序有关)
顺便说一句,我正在Mac OS X 10.6上开发Rail 2.3.5和Ruby 1.8.7,没有其他插件(除了基本安装)
关于如何调试的任何提示,为什么Rails的魔力似乎在这里失败了?这是版本问题吗?我可以追踪库中的代码并找到答案吗?有太多的“混入”模块,我找不到
fixtures
方法真正存在的地方。放弃后,我尝试重新安装/重建rail 3.0.0beta3。这解决了问题。我只能假设这是某种版本不匹配。使用ruby 1.8.7和rails 2.1.1,我通过在test\u helper.rb中设置self.use\u instanced\u fixtures=true来解决这个问题。使用rails 3.2,我发现在运行单个测试文件(指定test=/test/unit/foo.rb)时,没有加载固定装置。但是,在使用
ruby -Itest /test/unit/foo.rb
装置按预期加载。APIdock在需要查找方法文档时非常有用。谢谢你!apidocks是一个非常方便的工具,我将把它添加到我的工具箱中。但仍然不确定根本原因是什么。。。
ruby -Itest /test/unit/foo.rb