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搜索了一个多小时,没有运气。帮帮我?