0

我有以下内容:

  1 ENV["RAILS_ENV"] = "test"
  2 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
  3 require 'test_help'
  4 require 'shoulda'
  5 require 'factory_girl'
  6 FactoryGirl.find_definitions

我收到一个错误:

NameError: uninitialized constant OutboundEmail

我把它放在那里是因为当我在没有它的情况下运行测试时,它无法识别我的 OutboundMailer:

require 'test_helper'
  2 
  3 class OutboundMailerTest < ActionMailer::TestCase
  4 
  5   context "test creating email" do
  6 
  7     setup do
  8       @email = Factory.build(:outbound_email) #create email from factory
  9     end
 10 
 11     should "test sending of the outbound email" do
 12       @expected.subject = "#{@email.subject}"
 13       @expected.body    = "#{@email.body}"
 14       @expected.date    = Time.now
 15 
 16       assert_equal @expected.encoded, OutboundMailer.create_email(@expected.date).encoded
 17     end
 18   end
 19 end
4

1 回答 1

3

你有一个错字。你应该使用

Factory.find_definitions 

不是

FactoryGirl.find_definitions

正如您在 OutboundMailerTest 课程中所做的那样。

于 2011-01-12T02:36:29.123 回答