Sha256: bad4c5c3d8f7687438cb6e3148758c153f2e2bd7b6fa0558a3afec06e67e808b

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

require "bundler/setup"
require 'fileutils'

ENV['RACK_ENV'] = 'test'
$:.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 'dotenv'
require 'open3'

def base_dir
  File.expand_path "../", File.dirname(__FILE__)
end

def tmp_dir
  File.expand_path "tmp", base_dir
end

def bin_path
  File.expand_path "./bin/jekyll-auth", base_dir
end

def tear_down_tmp_dir
  FileUtils.rm_rf tmp_dir
end

def setup_tmp_dir
  tear_down_tmp_dir
  FileUtils.mkdir tmp_dir
  File.write File.expand_path("index.html", tmp_dir), "My awesome site"
  FileUtils.mkdir "#{tmp_dir}/some_dir"
  File.write File.expand_path("some_dir/index.html", tmp_dir), "My awesome directory"
  Dir.chdir tmp_dir
end

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

def execute_bin(env, *args)
  output, status = Open3.capture2e(env, bin_path, *args)
  raise "Command `#{bin_path} #{args.join(" ")}` failed: #{output}" if status != 0
  output
end

Dotenv.load
setup_tmp_dir

require_relative "../lib/jekyll-auth"
WebMock.disable_net_connect!

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-auth-2.0.0 spec/spec_helper.rb
jekyll-auth-1.0.3 spec/spec_helper.rb
jekyll-auth-1.0.2 spec/spec_helper.rb
jekyll-auth-1.0.1 spec/spec_helper.rb
jekyll-auth-1.0.0 spec/spec_helper.rb