4
試圖用RSpec和水豚測試OmniAuth,完全失敗。我應該如何用Rspec和Capybara測試Omniauth?
到目前爲止,spec_helper.rb
有:
# Enable omniauth testing mode
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:google] = OmniAuth::AuthHash.new({
:provider => 'google',
:uid => '1337',
:info => {
'name' => 'JonnieHallman',
'email' => '[email protected]'
}
})
而且我知道我需要把水豚測試spec/features
下。所以,我有:
require 'spec_helper'
describe "Authentications" do
context "without signing into app" do
it "sign in button should lead to Google authentication page" do
visit root_path
click_link "Login"
Authentication.last.uid.should == '1337'
end
end
end
,但我得到:
1) Authentications without signing into app sign in button should lead to Google authentication page
Failure/Error: Authentication.last.uid.should == '1337'
NameError:
uninitialized constant Authentication
# ./spec/features/omniauth_spec.rb:10:in `block (3 levels) in <top (required)>'
完全,徹底失去了。通過OmniAuth wiki,它確實沒有幫助;通過Stack Overflow搜索了一個多小時,沒有運氣。幫幫我?