Ruby 无法使用水豚和黄瓜测试获取推文
我没办法解决这个问题。基本上,我在这里尝试的是获得一个特定的页面,该页面使用Twitter gem和api来检索我帐户的tweet列表,并使用gem(如cucumber、capybara和api)对该方法进行测试和批准 app.rb:Ruby 无法使用水豚和黄瓜测试获取推文,ruby,cucumber,Ruby,Cucumber,我没办法解决这个问题。基本上,我在这里尝试的是获得一个特定的页面,该页面使用Twitter gem和api来检索我帐户的tweet列表,并使用gem(如cucumber、capybara和api)对该方法进行测试和批准 app.rb: require 'sinatra' require 'twitter' config = { :consumer_key => '...' , :consumer_secret => '...' , :access_toke
require 'sinatra'
require 'twitter'
config = {
:consumer_key => '...' ,
:consumer_secret => '...' ,
:access_token => '...' ,
:access_token_secret => '...'
}
get '/list_of_tweets' do
tweets = client.user_timeline(user)
@history = tweets.take(20)
unless @params[:operation].nil?
if @params[:operation] == 'favorite_count'
@history.sort_by!{|tweet| tweet.favorite_count}
@history.reverse!
elsif @params[:operation] == 'retweet_count'
@history.sort_by!{|tweet| tweet.retweet_count}
@history.reverse!
end
end
tweets的列表。功能:
Feature: list of tweets
Scenario: Fetching list of tweets
Given I am on the list of tweets page
Then I should see all my tweets
步骤u定义:
Given /^I am on the list of tweets page$/ do
visit ui_url '/list_of_tweets'
end
Then /^I should see all my tweets$/ do
@history.each do |tweet|
end
end
path.rb:
module NavigationHelpers
def path_to(page_name)
case page_name
when /the list of tweets page/
'/list_of_tweets'
end
end
World(NavigationHelpers)
我错过了什么?我是这些gems的新手这段代码有什么问题?您缺少实际的断言。@每当我在命令提示符下运行这段代码时,它都会说方法1场景和2步骤未定义,但很明显步骤定义在那里