问题
I'm trying to write a cucumber feature and rspec tests for my application for accessing the twitter streaming api with twitter-stream. I've got the following code:
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
the code for the method is:
def latest
token = @token.get_token
@stream = Twitter::JSONStream.connect(options)
items = []
@stream.each_item do |item|
items << item
end
items
end
But, predictably, it stalls on the timeline.latest call. How can I properly test the logic inside my latest
method?
来源:https://stackoverflow.com/questions/10592131/testing-eventmachine-with-cucumber