Skip to content
Extraits de code Groupes Projets
spec_helper.rb 2,09 ko
Newer Older
danielgrippi's avatar
danielgrippi a validé
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
Raphael's avatar
Raphael a validé
#   licensed under the Affero General Public License version 3 or later.  See
Raphael's avatar
Raphael a validé
#   the COPYRIGHT file.
Raphael Sofaer's avatar
Raphael Sofaer a validé
ENV["RAILS_ENV"] ||= 'test'
require File.join(File.dirname(__FILE__), '..', 'config', 'environment') unless defined?(Rails)
Raphael Sofaer's avatar
Raphael Sofaer a validé
require 'rspec/rails'
ilya's avatar
ilya a validé
require 'webmock/rspec'
WebMock::Config.instance.allow_localhost = false
include HelperMethods
# Force fixture rebuild
FileUtils.rm_f(File.join(Rails.root, 'tmp', 'fixture_builder.yml'))
Raphael Sofaer's avatar
Raphael Sofaer a validé
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
fixture_builder_file = "#{File.dirname(__FILE__)}/support/fixture_builder.rb"
support_files = Dir["#{File.dirname(__FILE__)}/support/**/*.rb"] - [fixture_builder_file]
support_files.each {|f| require f }
require fixture_builder_file
RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
Raphael Sofaer's avatar
Raphael Sofaer a validé
  config.mock_with :rspec

  config.use_transactional_fixtures = true
maxwell's avatar
maxwell a validé
    I18n.locale = :en
    stub_request(:post, "https://pubsubhubbub.appspot.com/")
Raphael's avatar
Raphael a validé
    $process_queue = false

  config.before(:each, :type => :controller) do
    self.class.render_views
  end

  config.after(:all) do
    `rm -rf #{Rails.root}/tmp/uploads/*`
  end
Raphael Sofaer's avatar
Raphael Sofaer a validé
end
Raphael Sofaer's avatar
Raphael Sofaer a validé
Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
  require f
end

ProcessedImage.enable_processing = false
def set_up_friends
  [local_luke, local_leia, remote_raphael]
end

def alice
  @alice ||= User.where(:username => 'alice').first
  @bob ||= User.where(:username => 'bob').first
  @eve ||= User.where(:username => 'eve').first
def local_luke
  @local_luke ||= User.where(:username => 'luke').first
end

def local_leia
  @local_leia ||= User.where(:username => 'leia').first
end

def remote_raphael
  @remote_raphael ||= Person.where(:diaspora_handle => 'raphael@remote.net').first
end
  @photo_fixture_name = File.join(File.dirname(__FILE__), 'fixtures', 'button.png')