Created
August 26, 2009 03:44
-
-
Save georg/175282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in features/env/mailtrap.rb to automatically run mailtrap for your Cucumber tests. | |
class Mailtrap | |
def self.start | |
@mailtrap_file = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'mailtrap.log')) | |
clear_mailtrap_file | |
@mailtrap = IO.popen("mailtrap run --file=#{@mailtrap_file}") | |
end | |
def self.clear_mailtrap_file | |
FileUtils.rm_f @mailtrap_file | |
end | |
def self.stop | |
Process.kill('HUP', @mailtrap.pid) | |
end | |
def self.content | |
File.read(@mailtrap_file) | |
end | |
end | |
Mailtrap.start | |
at_exit do | |
Mailtrap.stop | |
end | |
After do |scenario| | |
unless scenario.failed? | |
Mailtrap.clear_mailtrap_file | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment