difining stub raise IO::WaitReadable Exception

# in RSpec
socket.stub(:recv_nonblock).and_raise(IO::WaitReadable)

Error(IO::WaitReadable don't have method initialize)

Failure/Error: instance.handle_request(socket)
     NameError:
       undefined method `initialize' for module `IO::WaitReadable'

solution

IO::WaitReadable is extended to exception object.
c.f. module IO::WaitReadable (japanese)

socket.stub(:recv_nonblock).and_raise(StandardError.new.extend(IO::WaitReadable))