Sha256: 4fec8186691c495cd21718c9ef2b84960603c3fad43da40240208b71acfe3362

Contents?: true

Size: 1.69 KB

Versions: 11

Compression:

Stored size: 1.69 KB

Contents

require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'tempfile'
require 'stringio'

require 'carrierwave'
require 'carrierwave/mongoid'

Mongoid.configure do |config|
  config.connect_to('carrierwave_test')
end

def file_path( *paths )
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', *paths))
end

def public_path( *paths )
  File.expand_path(File.join(File.dirname(__FILE__), 'public', *paths))
end

CarrierWave.root = public_path

module CarrierWave
  module Test
    module MockFiles
      def stub_file(filename, mime_type=nil, fake_name=nil)
        f = File.open(file_path(filename))
        return f
      end

      def stub_tempfile(filename, mime_type=nil, fake_name=nil)
        raise "#{path} file does not exist" unless File.exist?(file_path(filename))

        t = Tempfile.new(filename)
        FileUtils.copy_file(file_path(filename), t.path)

        t.stub!(:local_path => "",
                :original_filename => filename || fake_name,
                :content_type => mime_type)

        return t
      end
    end

    module I18nHelpers
      def change_locale_and_store_translations(locale, translations, &block)
        current_locale = I18n.locale
        begin
          I18n.backend.store_translations locale, translations
          I18n.locale = locale
          yield
        ensure
          I18n.reload!
          I18n.locale = current_locale
        end
      end
    end
  end
end

class SIO < StringIO 
  attr_accessor :filename 
 
  def initialize(filename, *args, &block) 
    @filename = filename 
    super(*args, &block) 
  end
end

RSpec.configure do |config|
  config.include CarrierWave::Test::MockFiles
  config.include CarrierWave::Test::I18nHelpers
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
glebtv-carrierwave-mongoid-0.6.4 spec/spec_helper.rb
glebtv-carrierwave-mongoid-0.6.3 spec/spec_helper.rb
glebtv-carrierwave-mongoid-0.6.2 spec/spec_helper.rb
glebtv-carrierwave-mongoid-0.6.1 spec/spec_helper.rb
glebtv-carrierwave-mongoid-0.6.0 spec/spec_helper.rb
carrierwave-mongoid-0.6.0 spec/spec_helper.rb
carrierwave-mongoid-0.5.0 spec/spec_helper.rb
carrierwave-mongoid-0.4.0 spec/spec_helper.rb
carrierwave-mongoid-0.3.1 spec/spec_helper.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/carrierwave-mongoid-0.3.0/spec/spec_helper.rb
carrierwave-mongoid-0.3.0 spec/spec_helper.rb