任何人都有嘲笑功能測試中的Facebook請求的最佳做法的任何提示?它是否像添加所有適當的參數一樣簡單?有沒有辦法將這些出來?爲facebooker控制器編寫功能測試?
我使用facebooker,它配備了一個模擬服務:
# A mock service that reads the Facebook response from fixtures
# Adapted from http://gist.github.com/44344
#
# Facebooker::MockService.fixture_path = 'path/to/dir'
# Facebooker::Session.current = Facebooker::MockSession.create
但是,當我寫了一個基本的GET測試,它會嘗試到瀏覽器的Facebook頁面重定向添加應用程序,這是我假設表示嘲笑不起作用。
test "loads respondent" do
Facebooker::Session.current = Facebooker::MockSession.create
get :index
puts @response.body # => <html><body>You are being <a href="http://www.facebook.com/install.php?api_key=65e9d2c74b295cc5bcea935b584557f6&v=1.0&next=http%3A%2F%2Ftest.host%2Ffacebook">redirected</a>.</body></html>
end