I'm playing around with the tweetstream gem, which simplifies interaction with the Twitter streaming API. I'm streaming all tweets just like the code example shown on the gem's page:
TweetStream::Client.new.sample do |status|
puts "#{status.text}"
end
I've put this in a #capture
method with some simple logic to run the stream for only a few seconds and capture all the tweets (the status.text
strings) in an array. I'm not sure if I should use VCR here, either.
I want to write unit tests for #capture
. How would I stub out the stream of tweets? I'm guessing I'll have store tweets in either a file or a StringIO
object, but I don't know how to write the mock to handle whatever TCP interaction is going on with the streaming API.
Aucun commentaire:
Enregistrer un commentaire