Testing EventMachine with cucumber

家住魔仙堡 提交于 2019-12-10 18:17:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!