如何在规范中包含特定的帮助文件

时间:2014-12-01 00:57:17

标签: ruby-on-rails rspec

我不确定为什么这不起作用。我对omniauth进行了测试,并且有一个set_omniauth方法可以在下面的规范中自动调用(自动)。如果通过

调用,此测试将失败

rspec spec / controllers / sessions_controller_spec.rb

但是当整个套件通过rspec spec运行时传递。我如何包含spec/helpers/omniauth_helpers.rb文件?我试过了:

require 'omniauth_helpers'
require 'spec/helpers/omniauth_helpers'
require 'omniauth_helpers.rb'
require 'spec/helpers/omniauth_helpers.rb'

但他们不能工作。

这是我的规格:

require 'spec_helper'

describe SessionsController, "OmniAuth", task049: true do
  before do
    request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook] # is set in
  end

  it "task049: sets a session variable to the OmniAuth auth hash - see the set_omniauth() in spec/helpers/omniauth_helpers" do
    request.env["omniauth.auth"]['uid'].should == '1234fb'
  end
end

1 个答案:

答案 0 :(得分:0)

所以,这样做了:

require 'spec_helper'
require 'helpers/omniauth_helpers'


describe SessionsController, "OmniAuth", task049: true do

昨晚是深夜。