Sha256: b868890a4d7520cb0850a5e3c0e2a1cfed380bd8c7bf215b8d7806d938672ac6

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 Bytes

Contents

OmniAuth.config.test_mode = true

module OmniAuthSpecHelper
  %w(user admin selector).each do |factory|
    define_method("#{factory}_auth_hash") do 
      OmniAuth::AuthHash.new({
        provider: 'open_id', 
        uid: "http://openconferenceware.org/factory/#{factory}",
        info: { name: factory }
      })
    end
  end

  def mock_sign_in(factory)
    create_mock_user(factory)
    OmniAuth.config.mock_auth[:open_id] = send("#{factory}_auth_hash")
    visit OpenConferenceWare.mounted_path("/auth/open_id")
  end

  def create_mock_user(factory)
    auth_params = {provider: "open_id", uid: "http://openconferenceware.org/factory/#{factory}"}
    user = Authentication.where(auth_params).first
    unless user.present?
      user = create(factory)
      auth = create(:authentication, auth_params.merge(user: user))
    end

    return user
  end
end

RSpec.configure do |c|
  c.include OmniAuthSpecHelper
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
open_conference_ware-1.0.0.pre4 spec/support/omniauth.rb
open_conference_ware-1.0.0.pre3 spec/support/omniauth.rb
open_conference_ware-1.0.0.pre2 spec/support/omniauth.rb
open_conference_ware-1.0.0.pre1 spec/support/omniauth.rb