Vic*_*r S 1 testing fixtures mailer ruby-on-rails-3
我认为这是一个Rails约定,邮件夹具驻留在以邮件程序类名命名的文件夹中,并且该文件夹内部是以邮件程序类中的每个操作命名的夹具.
但是,当我运行我的单元测试,我发现轨道提升和错误,因为它试图将邮件类和邮件动作类放在一起后回落测试表名......这是奇怪的,我会假设轨道会更好地了解和忽视这些灯具仅用于邮件内容格式比较.
关于邮件程序夹具的Rails 3文档:
10.2.1固定装置的复仇
出于单元测试邮件的目的,固定装置用于提供输出应该如何看的示例.因为这些是示例电子邮件,而不是像其他灯具那样的Active Record数据,所以它们保存在它们自己的子目录中,而不是其他灯具.test/fixtures中目录的名称直接对应于邮件程序的名称.因此,对于名为UserMailer的邮件程序,fixture应位于test/fixtures/user_mailer目录中.
测试助手内容:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
fixtures :all
# Add more helper methods to be used by all tests here...
end
Run Code Online (Sandbox Code Playgroud)
我的灯具目录布局:
test/fixtures/card_sender_mailer/card_update_notificaiton.yml
Run Code Online (Sandbox Code Playgroud)
这是错误:
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'monkey_test.card_sender_mailer_card_update_notification' doesn't exist: DELETE FROM `card_sender_mailer_card_update_notification`
Run Code Online (Sandbox Code Playgroud)
我假设因为我正在加载所有灯具它也试图加载它,所以如何加载除邮件装置之外的所有灯具?
当我尝试在终端中使用rake加载灯具时,我收到类似的错误:
Tasks: TOP => db:fixtures:load
(See full trace by running task with --trace)
/Users/victorstan/Sites/ContactMonkey ? bundle exec rake db:fixtures:load
rake aborted!
Mysql2::Error: Table 'monkey_development.card_sender_mailer_card_update_notification' doesn't exist: DELETE FROM `card_sender_mailer_card_update_notification
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
765 次 |
最近记录: |