omniauth mock facebook response

Я хочу протестировать свой логин через facebook. Я использую чистый omniauth, w/o Devise. Я проверяю вики-страницу и делаю следующее:

helper for request specs

module IntegrationSpecHelper
  def login_with_oauth(service = :facebook)
    visit "/auth/#{service}"
  end
end

spec_helper.rb

    RSpec.configure do |config|
      config.include IntegrationSpecHelper, :type => :request
    end

    Capybara.default_host = 'http://example.org'
    OmniAuth.config.test_mode = true
    OmniAuth.config.add_mock(:facebook, {
    :provider => 'facebook',
    :uid => '12345',
    :user_info => {
        :name => 'dpsk'
      }
})

my spec

require 'spec_helper'

describe 'facebook' do
  it "should login with facebook", :js => true do
    login_with_oauth

    visit '/'
    page.should have_content("dpsk")
  end
end


#OmniAuth routes
  match "/auth/:provider/callback" => "sessions#create"
  match "/signout" => "sessions#destroy", :as => :signout
  match "/signin" => "sessions#signin", :as => :signin
  match "/auth/failure" => "sessions#failure", :as => :auth_failure

But in spec ничего не возвращается вместо моей подделки я получил ошибку:

Failure/Error: visit "/auth/facebook"
     You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

Where is my error?

7
задан Mikhail Nikalyukin 25 August 2011 в 13:26
поделиться