Guest User

Untitled

a guest
May 24th, 2018
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. When /^I connect to smtp on (.+)$/ do |server|
  2. @smtp = Net::SMTP.start(server, 25)
  3. end
  4.  
  5. When /^the sender is (\S+)$/ do |from|
  6. @from = from
  7. end
  8.  
  9. Then /^it should accept email to (\S+)$/ do |to|
  10. message = "a test message from cucumber-nagios"
  11. @from ||= "nobody@test.com"
  12. @response = @smtp.send_message message, @from, to
  13. end
  14.  
  15. Then /^the response should be (\d+)$/ do |code|
  16. @response.status.should == code
  17. end
  18.  
  19. Then /^it should reject email to (\S+)$/ do |to|
  20. message = "a test message from cucumber-nagios"
  21. @from ||= "nobody@test.com"
  22. lambda {
  23. @smtp.send_message message, @from, to
  24. }.should raise_error(Net::SMTPFatalError)
  25. end
  26.  
  27. Then /^it should close the connection successfully$/ do
  28. response = @smtp.finish
  29. response.status.should == "221"
  30. end
Add Comment
Please, Sign In to add comment