Matt Wynne wrote:
On 22 Aug 2009, at 13:09, Sławosz Sławiński wrote:
Hi,
I'm trying to test emails with Celerity. The problem is, because
Celerity browser uses environment 'cucumber', but Cucubmer runs in
'test'. Emails steps are running in 'test', so it is impossible to check
mails send in 'cucumber'. I think, I can use webrat for steps with email
sending, and cucmber for others (i.e. wiht Ajax). But maybe there is
more logical and elegant solution?
I'm not sure, but I think it's more likely the problem is that your
tests are running in a different process to the app you're testing, so
the usual railsey mail testing stuff doesn't work.
We got around this by writing the emails to disk, then having the
tests check the files on disk to validate the emails. Could that work
for you?
I agree with Matt. You have three options to address this:
1. Run your server is the same process as Cucumber. If you are using
Rails then I'd reccomend the mainline lib:
http://github.com/gaffo/mainline/tree/master If you are using another
Ruby framework this is trivially done by starting up the server in a new
thread.
Or.. you can go the route Matt suggested. If you are using email-spec
you can use active record mailer or action mailer cache delivery. The
ActiveRecord Mailer will work out of the box right now. For the
ActionMailer cache lib you will need to use these forks ATM:
http://github.com/liangzan/action_mailer_cache_delivery/tree/master
http://github.com/liangzan/email-spec/tree/master
I plan on merging the above into email spec soon.
Even if you are not using email-spec then the above libs would be helpful.
-Ben
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users