James Byrne wrote:
I need some help with this. I have installed email-spec (courtesy of
BMabey) and I have configure things thusly:
Scenario: E-Mail Exchange Rates to notify parties
Given a currency exchange feed from the Bank of Canada
When the currency exchange retrieval script runs
Then I should receive an email
Then /should receive (an|\d+) e-?mails?/ do |amount|
amount = 1 if amount == "an"
unread_emails_for(current_email_address).size.should == amount.to_i
end
../environments/test.rb
# Tell ActionMailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.gem 'bmabey-email_spec', :lib => 'email_spec'
class MailerPublic < ActionMailer::Base
def forex_daily_notice(address,rates)
rates_effective = Date.today.to_s(:db)
recipients address.to_a
from "forexserv...@harte-lyne.ca"
reply_to "supp...@harte-lyne.ca"
subject "#{rates_effective} - Foreign Exchange Rates Notice"
body :rates_effective => rates_effective, :rates => rates
end
end
./views/mailer_public/forex_daily_notice.text.plain.erb
Canada Customs foreign currency exchange rates for
currency conversion of shipments made on <%...@rates_effective%>
When I run this
./bin/script.rb
...
# Format and email the results.
if fx_hash_array
puts "got an array"
send_to = 'test_em...@example.com'
MailerPublic.deliver_forex_daily_notice!(send_to,fx_hash_array)
puts ActionMailer::Base.deliveries.length
ActionMailer::Base.deliveries.each { |m| puts m }
end
Then I see this:
got an array
0
This is my first attempt at using ActionMailer so no doubt I have
overlooked something basic. Can anyone tell me what it is?
Looks right to me. To be honest though I have not used ActionMailer
outside of Rails (where it just works out of the box). I don't see
anything wrong with the approach you are taking. Maybe the rails
mailing list could provide better advice. Sorry, I couldn't be of any
help.
-Ben
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users