Skip to content

Instantly share code, notes, and snippets.

@pmenglund
Created April 28, 2010 13:34
Show Gist options
  • Save pmenglund/382136 to your computer and use it in GitHub Desktop.
Save pmenglund/382136 to your computer and use it in GitHub Desktop.
When /^I connect to smtp on (.+)$/ do |server|
@smtp = Net::SMTP.start(server, 25)
end
When /^the sender is (\S+)$/ do |from|
@from = from
end
Then /^it should accept email to (\S+)$/ do |to|
message = "a test message from cucumber-nagios"
@from ||= "nobody@test.com"
@response = @smtp.send_message message, @from, to
end
Then /^the response should be (\d+)$/ do |code|
@response.status.should == code
end
Then /^it should reject email to (\S+)$/ do |to|
message = "a test message from cucumber-nagios"
@from ||= "nobody@test.com"
lambda {
@smtp.send_message message, @from, to
}.should raise_error(Net::SMTPFatalError)
end
Then /^it should close the connection successfully$/ do
response = @smtp.finish
response.status.should == "221"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment