I am currently experimenting with ActionController::Live and I can't figure out how to test this properly.
In my controller I have this written
response.stream.write("event: #{event}\n")
response.stream.write("data: #{post.to_json}\n\n")
But when I inspect the object in my rspec test I see this
(rdb:1) response.stream.instance_variable_get(:@buf)
["event: event\n"]
When I write the "data" to the stream, I can't figure out whyit doesn't show up in the array. When I remove the first response.stream.write line the buf returns an empty array.
Figured out the issue. Calling to_json in the stream.write doesn't add the stream into the buf instance variable. so I stubbed out to_json and forced a return value, now I can make sure that the stream is writing properly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With