Sha256: 95480a0b0679a27942d7e4f7c57b818b5d30ba22f2c19ff40cc0c12e07daa939

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
ENV['RACK_ENV'] = 'test'
require 'rspec'
require 'database_cleaner'
#require 'webmock/rspec'
require File.join(File.dirname(__FILE__), '../lib', 'perkins')
require "pry"
require "git"
require 'rack/test'

require "support/auth"
require "support/github_api"
require 'sidekiq/testing'

require 'dotenv'
Dotenv.load

module XhrHelpers

  def xhr(path, params = {})
    verb = params.delete(:as) || :get
    send(verb,path, params, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest")
  end
  alias_method :ajax, :xhr
end

RSpec.configuration.include XhrHelpers #, :type => :controller

RSpec.configure do |config|

  config.include(Rack::Test::Methods)
  config.include(SinatraAuthGithubTestHelper)

  def perkins_app
    Perkins.application do
      config do |c|
        c.sse_endpoint         = ENV['ENDPOINT']
        c.port                 = ENV['PORT']
        c.redis                = {host: "localhost"}
        c.database             = File.expand_path("../../examples/config/database.yml", __FILE__)
        c.github_client_id     = ENV['GITHUB_CLIENT_ID']
        c.github_client_secret = ENV['GITHUB_SECRET']
      end
    end
  end

  #WebMock.disable_net_connect!(:allow => 'coveralls.io')

  config.raise_errors_for_deprecations!

  config.before(:all) do
    perkins_app
    @test_repo = "#{test_github_login}/#{test_github_repository}"
    @test_org_repo = "#{test_github_org}/#{test_github_repository}"
  end

  config.before(:suite) do
    perkins_app
    DatabaseCleaner.clean_with(:truncation)
  end

  # this runs before each *_spec.rb, not before ALL specs
  config.before(:all) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  #config.after(:each) do
  #  DatabaseCleaner.clean
  #end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
perkins-0.0.5 spec/spec_helper.rb