English 中文(简体)
转而采用综合Auth试验模式,在使用Cucumber公司时不会再提出要求
原标题:Turning on test mode in OmniAuth does not redirect requests when using Cucumber

我正在尝试测试我的<https://github.com/intridea/omniauth” rel=“nofollow”>OmniAuthlogin过程,在请求/auth/facebook时提供微薄认证薄膜,如:here

用户——管理。

Feature: User management
    @omniauth_test
    Scenario: Login
        Given a user exists
        And that user is signed in

网络-步骤.rb

...
And /^that user is signed in$/ do
  visit "/auth/facebook"
end
...

页: 1

Before( @omniauth_test ) do
  OmniAuth.config.test_mode = true
  p "OmniAuth.config.test_mode is #{OmniAuth.config.test_mode}"
  # the symbol passed to mock_auth is the same as the name of the provider set up in the initializer
  OmniAuth.config.mock_auth[:facebook] = {
      "provider"=>"facebook",
      "uid"=>"uid",
      "user_info"=>{"email"=>"[email protected]", "first_name"=>"Test", "last_name"=>"User", "name"=>"Test User"}
  }
end

After( @omniauth_test ) do
  OmniAuth.config.test_mode = false
end

成果

Feature: User management

  @omniauth_test
  Scenario: Login                # features/用户——管理。:3
"OmniAuth.config.test_mode is true"
    Given a user exists     # features/step_definitions/pickle_steps.rb:4
    And that user is signed in # features/step_definitions/网络-步骤.rb:40
      No route matches [GET] "/auth/facebook" (ActionController::RoutingError)
      ./features/step_definitions/网络-步骤.rb:41:in `/^that user is signed in$/ 
      features/testing.feature:5:in `And that user is signed in 
问题回答

你们应当把这两条放在试验的初始阶段:

request.env["devise.mapping"] = Devise.mappings[:user] 
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]

在座标/支持栏目下排出以下位置,并标出您的设想,即:

Before( @omniauth_test ) do  
  OmniAuth.config.test_mode = true  

  # the symbol passed to mock_auth is the same as the name of the provider set up in the initializer
  OmniAuth.config.mock_auth[:facebook] = {
   :provider =>  facebook ,
   :uid =>  1234567 ,
   :info => {
     :nickname =>  test ,
     :email =>  [email protected] ,
     :name =>  Test User ,
     :first_name =>  Test ,
     :last_name =>  User ,
     :location =>  California ,
     :verified => true
    }.stringify_keys!
  }.stringify_keys!
end

After( @omniauth_test ) do
  OmniAuth.config.test_mode = false
end

问题不在于您的检验。 它与你的路线一致,或更具体地说,是 omni。

你们是否相信你们在编织/初创者/异构者中制定了面对面的战略?

https://github.com/mkdynamic/omniauth-facebook”rel=“nofollow”https://github.com/mkdynamic/omniauth-facebook

此外,铭记在增加新战略之后,重新启用你的网络服务器。 (我一度;)





相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签