aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
blob: 5a8d67c3ccbb15dd02f0a9e6664d35b8e7a77442 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'rubygems'
require 'spork'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.
  
  # Configure Rails Environment
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../dummy/config/environment.rb",  __FILE__)
    
  require 'rspec/rails'
  require 'capybara/rspec'
  require 'database_cleaner'
  
  require 'refinery/testing/factories'
  require 'refinery/testing/controller_macros'
  require 'refinery/testing/request_macros'

  Rails.backtrace_cleaner.remove_silencers!

  Dir[
    File.expand_path("../support/*.rb", __FILE__),
    File.expand_path("../factories/*.rb", __FILE__)
  ].each {|f| require f}

  RSpec.configure do |config|
    config.mock_with :rspec
    config.use_transactional_fixtures = false
    
    config.before(:suite) do
      DatabaseCleaner.strategy = :truncation
    end
    
    config.before(:each) do
      DatabaseCleaner.start
    end
    
    config.after(:each) do
      DatabaseCleaner.clean
    end
    
    config.include Devise::TestHelpers, :type => :controller
    config.extend Refinery::ControllerMacros::Authentication, :type => :controller
    config.extend Refinery::RequestMacros::Authentication, :type => :request
  end
end

Spork.each_run do
  # This code will be run each time you run your specs.
end