Sha256: db83bb5b2a09d3826ff043d05cf928d1c83f9ca42cbb69fb1a2dd6fe161f41a0

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

ENV['RACK_ENV'] = 'test'

require 'rubygems'
require File.expand_path('../../lib/rest-assured', __FILE__)
require 'rspec'
require 'shoulda-matchers'
require 'capybara/rspec'
require 'rack/test'
require 'database_cleaner'

Capybara.app = RestAssured::Application

def app
  RestAssured::Application
end

DatabaseCleaner.strategy = :truncation

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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-assured-0.1.1 spec/spec_helper.rb
rest-assured-0.1.0 spec/spec_helper.rb