public
Fork of courtenay/altered_beast
Description: Ground-up rewrite of Beast, a Ruby on Rails forum.
Homepage: http://activereload.lighthouseapp.com/projects/7537-altered-beast/
Clone URL: git://github.com/technoweenie/altered_beast.git
altered_beast / spec / spec_helper.rb
100644 30 lines (26 sloc) 0.943 kb
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
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec'
require 'spec/rails'
require 'rspec_on_rails_on_crack'
require 'model_stubbing'
require File.dirname(__FILE__) + "/model_stubs"
require 'ruby-debug'
Debugger.start
 
Spec::Runner.configure do |config|
  config.use_transactional_fixtures = true
  config.use_instantiated_fixtures = false
  config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
 
  def current_site(site)
    @site = sites(site)
  end
 
  # Sets the current user in the session from the user fixtures.
  def login_as(user)
    controller.stub!(:current_user).and_return(@user = user ? users(user) : nil)
  end
 
  def authorize_as(user)
    @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
  end
end