工厂女孩和 has_one
这是我的模型: Class Audition belongs_to :video end Class Video has_one :audition end 和我的工厂: Factory.define :video do |v| v.filename {…
Authlogic:在同一测试中登录两次
使用 Authlogic 进行测试时,有什么方法可以注销并登录另一个用户吗? 下面的测试用例失败了, class MessagesControllerTest < ActionController::Te…
访问*其他*工厂中的factory_girl工厂
我在 Rails 应用程序中使用 factory_girl 插件。对于每个模型,我都有一个相应的 ruby 文件,其中包含工厂数据,例如 Factory.define :valid_thin…
单元测试轨道时的 ActiveSupport::TestCase 与 Test::Unit::TestCase
我最近注意到,如果我的测试子类 Test::Unit::TestCase,我的测试数据库在运行后没有被清理。如果我的测试子类为 ActiveSupport::TestCase,则所有内…
Factory_girl 关联验证
我有一个问题,我有一个父模型 Foo,它同时具有 has_many :bars 和 has_many :bazes。最后,我还有一个连接模型 BarBaz,其中 belongs_to :bar 和 bel…
在黄瓜中与factory_girl建立关联的最佳实践是什么?
我通常使用此步骤来设置与factory_girl的记录: Given /^the following (.+) records?:$/ do |factory, table| table.hashes.each do |hash| Factory(…
应该+ FactoryGirl:我可以让我的测试更快吗?
我正在寻找一种方法来加快我的 Shoulda + FactoryGirl 测试。 我尝试测试的模型 (StudentExam) 与其他模型有关联。在我创建 StudentExam 之前,这些关…
将装置转换为 Rails 中的 Factory Girl
我想将我的装置迁移到 Rails 中的“Factory Girl”。 有没有简单的方法可以转换factories.rb 文件中的所有yml 文件?…
如何在 Factory Girl 中创建 has_and_belongs_to_many 关联
鉴于以下情况, class User < ActiveRecord::Base has_and_belongs_to_many :companies end class Company < ActiveRecord::Base has_and_belongs_to_…
使用shoulda和factory_girl测试REST - destroy
我正在使用shoulda和factory_girl开发REST测试。 下面的代码 context "on :delete to :destroy" do setup do @controller = NewsArticlesController.n…
清除 Rails 中单元测试和功能测试之间的测试数据库 (factory_girl)
最近,我从 Fixtures 切换到 Factory_girl 来测试我的 Ruby on Rails 应用程序。 如果我运行 rake test:units 来运行 /units 目录中的测试,它们都会…
使用 Test::Unit 和 Shoulda 设置 Factory Girl
我正在尝试在 Ruby on Rails 中使用 Test::Unit 和 Shoulda 设置 Factory Girl。 我已经安装了 gem,在 test/factories 目录下创建了工厂文件,并在 t…
在使用 Factory Girl 工厂进行测试时,如何覆盖 AASM 中的 :set_initial_state?
更新 答案如下。 如果链接的站点消失,您可以使用 mocha 来存根初始状态并防止覆盖,如... require 'mocha' class OrderTest < ActiveSupport::TestCa…