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 53 54 55 56 57 58 59
|
begin
require 'simplecov'
SimpleCov.start do
add_filter 'spec'
end
rescue LoadError
# SimpleCov ain't available - continue
end
if ENV["TRAVIS"]
require "coveralls"
Coveralls.wear!("rails")
end
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'asset_sync'
require 'rspec'
RSpec.configure do |config|
config.mock_framework = :rspec
end
shared_context "mock without Rails" do
before(:each) do
if defined? Rails
Object.send(:remove_const, :Rails)
end
allow(AssetSync).to receive(:log)
end
end
shared_context "mock Rails" do
before(:each) do
Object.send(:remove_const, :Rails) if defined? Rails
Rails = double 'Rails'
allow(Rails).to receive(:env).and_return('test')
allow(Rails).to receive_messages :application => double('application')
allow(Rails.application).to receive_messages :config => double('config')
allow(Rails.application.config).to receive_messages :assets => ActiveSupport::OrderedOptions.new
Rails.application.config.assets.prefix = '/assets'
allow(AssetSync).to receive(:log)
end
end
shared_context "mock Rails without_yml" do
include_context "mock Rails"
before(:each) do
set_rails_root('without_yml')
allow(Rails).to receive(:public_path).and_return(Rails.root.join('public').to_s)
end
end
def set_rails_root(path)
allow(Rails).to receive(:root).and_return(Pathname.new(File.join(File.dirname(__FILE__), 'fixtures', path)))
end
|