Sha256: aca9e994d2248353b338842008a156d17fb0284840a887f20d97bc364ee15ae7

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

class AuthenticationFactory
  attr_reader :user_token, :user_email

  def initialize(user_token:, user_email:)
    @user_token = user_token
    @user_email = user_email
  end

  def to_hash
    {
      userToken: user_token,
      userEmail: user_email,
    }
  end

  def set_headers(session)
    session.header('X-User-Token', @user_token)
    session.header('X-User-Email', @user_email)
  end
end

FactoryGirl.define do
  factory :authentication, class: AuthenticationFactory do
    skip_create

    transient do
      user
    end

    initialize_with do
      user_token ||= user.authentication_token
      user_email ||= user.email
      new(
        user_token: user_token,
        user_email: user_email,
      )
    end
  end

  factory :invalid_authentication, class: AuthenticationFactory do
    initialize_with do
      new(
        user_token: 'non existent',
        user_email: 'no_such@example.com',
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-ios-rails-1.0.2 spec/dummy/spec/factories/authentications.rb
devise-ios-rails-1.0.1 spec/dummy/spec/factories/authentications.rb
devise-ios-rails-1.0.0 spec/dummy/spec/factories/authentications.rb