곧 할인이 만료되면 사용자에게 오전 10시에 알려 드리고 싶습니다. 나는 heroku의 시간별 cron을 사용하고 있습니다. Ruby 1.8.7에서 Rails 3.0.9를 사용 중입니다. lib/tasks/cron에 다음 cron.rake가 있습니다.오이로 반복 크론 작업 테스트
# Notify users with expiring claims
puts "Notifying users with expiring claims..."
if Time.zone.now.hour == 10
Claim.expiring_tomorrow.reject(&:redeemed?).compact.each do |claim|
Mailer.delay.notify_customer_claim_expiration(claim)
claim.update_attribute(:expiration_notified, true)
end
end
puts "done."
그게 훌륭합니다.
Scenario: Not receiving a expiration reminder too early
Scenario: Receiving a expiration reminder only once
Scenario: Not receiving a reminder for a redeemed claim
을 그래서 나는 다음과 같은 기능 썼다 : 다음 cron.steps 단계 정의와
Feature: Being reminded that a claimed discount is expiring
Background:
Given the hourly cron job exists
Scenario: Not receiving a expiration reminder too early
And the hourly cron job has fired
Scenario: Receiving a expiration reminder only once
And the hourly cron job has fired
Scenario: Not receiving a reminder for a redeemed claim
And the hourly cron job has fired
:
And /^the hourly cron job exists$/ do
require "rake"
@rake = Rake::Application.new
Rake.application = @rake
Rake.application.rake_require "lib/tasks/cron"
end
And /^the hourly cron job has fired$/ do
Rake::Task["cron"].invoke
end
내 문제는 내가 오이에 세 가지 시나리오를 테스트해야한다는 것입니다
각 시나리오를 개별적으로 실행하면 통과합니다. 나는 모든 기능을 실행하면, 그와 두 번째 (안 제 1 호) 시나리오에 실패
RuntimeError: Don't know how to build task 'cron'
레이크 첫 번째 시나리오를지나 지속 또는 두 번째 시나리오가 실행되기 전에 재설정 할 필요가없는 것 같다. ..?
감사합니다 ... G
고마워. 나는 이것을 끝내기로 끝냈다 : –