twitter-stream を使用して Twitter ストリーミング API にアクセスするためのアプリケーション用のキュウリ機能と rspec テストを作成しようとしています。私は次のコードを持っています:
Then /^I should see the latest (\d+) tweets from my timeline$/ do |num|
timeline = Starling::Timeline::Mine.new(@store)
EventMachine::run {
tweets = timeline.latest
timeline.stop
}
tweets.length.should == num.to_i
end
メソッドのコードは次のとおりです。
def latest
token = @token.get_token
@stream = Twitter::JSONStream.connect(options)
items = []
@stream.each_item do |item|
items << item
end
items
end
しかし、予想通り、timeline.latest 呼び出しで停止します。latest
メソッド内のロジックを適切にテストするにはどうすればよいですか?