0
私は、次のしている:test_helper.rbファイルにfactory_girlを設定してshouldaと一緒に使用するにはどうすればよいですか?
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
を私はエラーを取得する:私はそれなしで私のテストを実行したとき、それは私のOutboundMailerを認識しなかったので、
NameError: uninitialized constant OutboundEmail
私はそこにそれを置く:
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
Rails 2.3.x、またはRails 3? –