Sha256: c7ddacf8ac319229d2092e6b217f87084084408e5b95175871a2b518882950ac

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 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 |app|
      config do |c|
        c.sse_endpoint = "http://localhost:3000/sse"
        c.redis = {namespace: "perkins:test"}
        c.database = "./examples/database.yml"
        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

2 entries across 2 versions & 1 rubygems

Version Path
perkins-0.0.3 spec/spec_helper.rb
perkins-0.0.2 spec/spec_helper.rb