【问题标题】:spec and fabrication validating mailer. Fabrication::UnfabricatableError: No class found for规格和制造验证邮件。 Fabrication::UnfabricatableError: No class found for
【发布时间】:2013-10-01 09:23:44
【问题描述】:

我正在使用 rspec 验证邮件程序。 问题是当我想测试扩散(多个交付者邮件程序)时,rspec 给我一个错误。

我的制造商:

Fabricator(:message) do
  email(count: 1) {"proof@example.com" }
  subject:"Hackety-hack email"
  body:"This is an email from hackety-hack.com"
end

Fabricator(:diffusion) do
  email(count: 3) {"proof#{i}@example.com" }
  subject:"Hackety-hack email"
  body:"This is an email from hackety-hack.com"
end

在我的 message_mailer_spec.rb 我有

it "Works the diffusion" do
  diffusion.to.should eq(["proof@example.com", "proof2@example.com"])
end

当我尝试通过测试时,会出现很多错误。主要(我认为):

  10) MessageMailer Works the diffusion
 Failure/Error: let(:diffusion) { MessageMailer.new_message(Fabricate(:diffusion), Array("proof@example.com", "proof2@example.com", "proof3@example.com"))}
 Fabrication::UnknownFabricatorError:
   No Fabricator defined for 'diffusion'

为什么?我已经创建了扩散。 谁能帮帮我?

提前致谢

【问题讨论】:

    标签: ruby ruby-on-rails-3 rspec fabrication-gem


    【解决方案1】:

    如果 Diffusion 对象不是红宝石模型,则制造宝石很难找到它。就我所见,它看起来像是 Message 模型的子类。

    试试这个:

    Fabricator(:diffusion, from: message)  do
      email(count: 3) {"proof#{i}@example.com" }
      subject:"Hackety-hack email"
      body:"This is an email from hackety-hack.com"
    end
    

    这应该可以解决错误。有关定义制造商的更多信息,请查看here

    【讨论】:

      猜你喜欢
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      • 2018-07-04
      相关资源
      最近更新 更多