我想测试一些需要延迟工作才能在黄瓜上工作的功能。我已经定义了以下步骤:如何使用黄瓜测试基于延迟工作的功能集成?
Given /^jobs are being dispatched$/ do
Delayed::Worker.new.work_off
end
现在,我试图测试电子邮件通知。所以,我有以下情形:
Scenario: Receiving email when signing up
Given I am on the signup page
And I fill in "user[email]" with "[email protected]"
And I fill in "user[password]" with "password"
And I fill in "user[password_confirmation]" with "password"
And I press "Sign up"
Then I should be on the homepage
Given jobs are being dispatched
Then "[email protected]" should receive 1 emails
的应该接收N电子邮件步骤由email_spec定义,定义为:
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
unread_emails_for(address).size.should == parse_email_count(amount)
end
所以测试失败告诉我,我接受了0电子邮件(在这个测试中[email protected]被真正的电子邮件取代,我没有收到任何东西)。我怀疑这个工人并没有真正开始。我应该检查什么?顺便说一下,当我在开发模式下测试时,我确实收到了这封电子邮件。
感谢
编辑:
它看起来像我得到一个的SQLite3 :: BusyException:
的SQLite3 :: BusyException:数据库被锁定:INSERT INTO“delayed_jobs “....
Now to inve为什么以及我如何摆脱这一点?任何想法? (除了将我的数据库移动到PostgreSQL或MySQL)。
编辑: 好吧,我从SQLite的移动到PostgreSQL,该记录被插入Delayed::Job
但电子邮件测试失败。
配置/环境/ test.rb文件包含:
config.action_mailer.delivery_method = :test
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "[email protected]",
:password => "mypassword",
:authentication => "plain",
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
什么是config.action_mailer.delivery_method在config.rb中设置为?是否将记录插入到delayed_jobs表中? – 2011-05-17 20:16:09
@Andy - 由于SQLite3 :: BusyException,看起来没有插入记录。 – 2011-05-18 10:44:13
好记录正在插入到delayed_job表中,但测试仍然失败。我添加了config/environments/test.rb文件的内容。 – 2011-05-19 13:47:42