mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
5dd835e4ca
getting closed before the redirection thread had a chance to copy it's contents into it.
24 lines
618 B
Ruby
24 lines
618 B
Ruby
RSpec::Matchers.define :include_response do |expected_response|
|
|
read_timeout = 2
|
|
read_bytes = 4096
|
|
response = ""
|
|
|
|
match do |read_io|
|
|
found_response = false
|
|
|
|
while !found_response && IO.select([read_io], nil, nil, read_timeout) do
|
|
response += read_io.read_nonblock(read_bytes)
|
|
found_response = response.include?(expected_response)
|
|
end
|
|
|
|
found_response
|
|
end
|
|
|
|
failure_message_for_should do |actual|
|
|
"expected #{response} to include #{expected_response}"
|
|
end
|
|
|
|
failure_message_for_should_not do |actual|
|
|
"expected #{response} to not include #{expected_response}"
|
|
end
|
|
end
|