On 7 Oct 2008, at 15:33, David Chelimsky wrote:
Regardless, if you really care about the specific instance you can
do this:
lambda {
@connection.receive_data("UPDATE\n")
}.should raise_error {|error| error.should equal(@error)}
If what you care about is the message, you can expect specific
messages using strings or regexps:
Thanks - that snippet does exactly what I want. Basically I want tee
pipe-fitting for errors - the code now looks like this:
class Connection < EventMachine::Connection
attr_accessor :server
def receive_data(data)
if data.chomp == "UPDATE"
handle_update
else
send_data("ERROR: Unknown command\n")
end
end
def unbind
raise @error if @error
end
private
def handle_update
server.check_feeds
rescue StandardError => @error
send_data("ERROR: [EMAIL PROTECTED]")
close_connection_after_writing
else
send_data("OK\n")
end
end
So I don't care about the exception beyond extracting enough data to
feed back through the socket.
Cheers
Ashley
--
http://www.patchspace.co.uk/
http://aviewfromafar.net/
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users