我正在尝试编写一个 rspec2 测试,但它却给了我一个错误。我知道测试现在没有测试任何特别的东西。但我稍后会添加更多代码,我想先通过这部分。
context "/login/twitter" do
before(:each) do
request_token = double("request_token")
request_token.stub(:authorize_url).and_return("http://api.twitter.com/oauth/authenticate?oauth_token")
TwitterService.any_instance.stub(:authentication_request_token).and_return(request_token)
get '/login/twitter'
end
it "should redirect to twitter authorized url" do
last_response.header["Location"].should include "http://api.twitter.com/oauth/authenticate?oauth_token"
end
it "should redirect back to home page if error occurs" do
end
end
这是我的控制器
get '/login/twitter' do
begin
request_token = TwitterService.new.authentication_request_token
session[:request_token_twitter] = request_token
logger.info(request_token.authorize_url)
redirect request_token.authorize_url
rescue Exception => e
logger.error(e.message)
redirect '/'
end
end
这是我得到的错误
1) Server /login/twitter should redirect to twitter authorized url
Failure/Error: get '/login/twitter'
TypeError:
singleton can't be dumped
# ./spec/twitter_route_spec.rb:25:in `block (3 levels) in <top (required)>'
不知道我错过了什么。