Sha256: 8916b88c494e357f5a22a5f90e696c5691d1616b99f4647fae47debab69ea9bf

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

require 'rubygems'

if RUBY_VERSION =~ /^1.9/
  begin
    require 'simplecov'
    SimpleCov.start do
      at_exit {} # reset built in at_exit or else it gets triggered when RestAssured::Server.stop is called from tests
      add_filter "/spec/"
      add_filter "/sinatra/"
    end
  rescue LoadError
  end
end

require 'spork'

$:.unshift(File.expand_path('../../lib'), __FILE__)

Spork.prefork do
  require 'rspec'
  require 'capybara/rspec'
  require 'rack/test'
  require 'database_cleaner'
  require 'awesome_print'
  require File.expand_path('../support/custom_matchers', __FILE__)
  require File.expand_path('../support/reset-singleton', __FILE__)

  ENV['RACK_ENV'] = 'test'

  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.configure do |c|
    c.include Capybara::DSL
    c.include Rack::Test::Methods
    c.include XhrHelpers

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

    c.after(:each) do
      DatabaseCleaner.clean
    end

    c.before(:each, :ui => true) do
      header 'User-Agent', 'Firefox'
    end

    c.before(:each, :ui => false) do
      header 'User-Agent', nil
    end

    if defined?(SimpleCov)
      c.after(:suite) do
        SimpleCov.result.format!
      end
    end
  end
  require 'rest-assured/config'
  DB_OPTS = { :dbuser => ENV['TRAVIS'] ? "''" : "root", :adapter => 'mysql' }
  RestAssured::Config.build(DB_OPTS)

  require 'rest-assured'
  require 'rest-assured/application'
  require 'shoulda-matchers'

  Capybara.app = RestAssured::Application

  def app
    RestAssured::Application
  end

  DatabaseCleaner.strategy = :truncation
end

Spork.each_run do
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-assured-1.1.1 spec/spec_helper.rb