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 に答える