lib/seatbelt/assert_mail.rb in seatbelt-0.1.0 vs lib/seatbelt/assert_mail.rb in seatbelt-0.1.1
- old
+ new
@@ -22,11 +22,18 @@
end
def got_mail?(mail, options={})
return false if options[:to] && !mail.to.include?(options[:to])
return false if options[:from] && !mail.from.include?(options[:from])
- return false if options[:subject] && (mail.subject !~ /#{options[:subject]}/)
+
+ case options[:subject]
+ when String
+ return false if mail.subject != options[:subject]
+ when Regexp
+ return false if mail.subject !~ /#{options[:subject]}/
+ end
+
return false if options[:cc] && !mail.cc.include?(options[:cc])
return false if options[:bcc] && !mail.bcc.include?(options[:bcc])
if options[:body]
Array(options[:body]).each do |element|
if !mail.body.encoded.match(element)
@@ -38,11 +45,10 @@
true
end
end
end
-
-if Module.const_defined?(:ActionMailer)
+if Object.const_defined?(:ActionMailer)
class Test::Unit::TestCase
include Seatbelt::AssertMail
end
end