【发布时间】:2013-02-22 05:09:45
【问题描述】:
我收到一个错误,我的方法没有定义。错误是“未定义的局部变量或方法 'mock_auth_hash',尽管在 spec_helper 中包含定义 mock_auth_hash 的模块。
我正在尝试使用omniauth 进行一些rspec 集成测试,我正在关注此链接https://gist.github.com/kinopyo/1338738
请帮我找出问题所在,因为我花了太多时间试图找出这个问题...也许我需要一双新的眼睛...
这是我的文件
spec->support->omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
OmniAuth.config.mock_auth[:facebook] = {'provider' =>"facebook",
'uid' =>"12345",
'info'=>{'name'=>"John Doe"},
'credentials'=>{'token'=>"AAABBBCCC"}}
end
end
spec->spec_helper.rb
RSpec.configure do |config|
.
.
.
config.include OmniauthMacros #I've also tried putting config.include(OmniauthMacros)
.
.
end
OmniAuth.config.test_mode = true
spec->requests->game_pages_spec.rb
describe "signing in" do
before {visit root_url}
mock_auth_hash
before {click_button "Login with Facebook"}
it {should have_selector('h1',text: 'Welcome')}
end
【问题讨论】:
标签: ruby-on-rails