我有以下内容:
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
答案 0 :(得分:3)
你有一个错字。你应该使用
Factory.find_definitions
不
FactoryGirl.find_definitions
正如您在OutboundMailerTest类中所做的那样。