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' => 'jon@test.com'
}
})
そして、Capybara テストを の下に配置する必要があることはわかっています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 で 1 時間以上検索しましたが、うまくいきませんでした。ヘルプ?