Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created February 3, 2012 20:48
Show Gist options
  • Save guilherme/1732428 to your computer and use it in GitHub Desktop.
Save guilherme/1732428 to your computer and use it in GitHub Desktop.
functional error
# acid_tests.rb
# Add another case:
# as you may see it not raises a logical error. it accepts multiple applications
describe "Two applications on the same server" do
it "emulates a simple mail list and respond to ping pongs" do
mailer.deliver_message(:from => "[email protected]",
:to => "[email protected]")
server.tick([Newman::Examples::SimpleList,Newman::Examples::PingPong])
messages = mailer.messages
assert_equal true, messages.any? { |message| message.subject == "You are not subscribed" }
assert_equal true, messages.any? { |message| message.subject == "unknown command" }
end
end
# wrong server.rb
module Newman
class << Server
def tick(apps)
mailer.messages.each do |request|
response = mailer.new_message(:to => request.from,
:from => settings.service.default_sender)
Array(apps).each do |a|
a.call(:request => request,
:response => response,
:settings => settings)
end
response.deliver
end
end
end
end
# right server.rb
module Newman
class << Server
def tick(apps)
mailer.messages.each do |request|
Array(apps).each do |a|
response = mailer.new_message(:to => request.from,
:from => settings.service.default_sender)
a.call(:request => request,
:response => response,
:settings => settings)
response.deliver
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment