Sha256: d9756f6011eeb81ead899ac23417928562bd3accd7a8a86aebdc03074d937267

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'fileutils'
require 'securerandom'

ENV['RACK_ENV'] = 'test'
ENV['GITHUB_CLIENT_ID'] = 'CLIENT_ID'
ENV['GITHUB_CLIENT_SECRET'] = 'CLIENT_SECRET'
$LOAD_PATH.push File.join(File.dirname(__FILE__), '..', 'lib')

require 'rack/test'
require 'sinatra/auth/github'
require 'sinatra/auth/github/test/test_helper'
require 'webmock/rspec'

require_relative '../lib/add-to-org'
WebMock.disable_net_connect!

RSpec.configure do |config|
  config.include(Sinatra::Auth::Github::Test::Helper)
end

def fixture_path(fixture)
  File.expand_path "./fixtures/#{fixture}", File.dirname(__FILE__)
end

def fixture(fixture)
  File.open(fixture_path(fixture)).read
end

def with_env(key, value)
  old_env = ENV[key]
  ENV[key] = value
  yield
  ENV[key] = old_env
end

class User < Warden::GitHub::User
  def self.make(attrs = {}, token = nil)
    default_attrs = {
      'login' => 'test_user',
      'name' => 'Test User',
      'email' => 'test@example.com',
      'company' => 'GitHub',
      'gravatar_id' => 'a' * 32,
      'avatar_url' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png'
    }
    default_attrs.merge! attrs
    User.new(default_attrs, token)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
add-to-org-3.0.3 spec/spec_helper.rb