Sha256: 8da8da5c76d6d09eabc92f0c82f31327fdb0fa4e43d004cfbbd75257739a18e6

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'rspec'
require 'active_record'
require 'paperclip'
require 'paperclip-dimension'
require 'paperclip/railtie'

# mocking Rails.root & Rails.env used in Paperclip::Interploration
module Rails
  def self.root
    File.dirname(__FILE__) + "/.."
  end

  def self.env
    "test"
  end

  def self.logger
    nil
  end
end

# need to manually call this
Paperclip::Railtie.insert

# turn off logging
Paperclip.options[:log] = false

# use sqlite3 memory store
ActiveRecord::Base.establish_connection({
  :adapter    =>    'sqlite3',
  :database   =>    ':memory:'
})

# create tables
ActiveRecord::Schema.define do
  create_table :posts do |t|
    t.has_attached_file :image
    t.has_attached_file :another_image
  end
end

# define model
class Post < ActiveRecord::Base
  extend Paperclip::Dimension::ClassMethods
  has_attached_file :image, :styles => {
    :large    =>    ['350x350>',     :jpg],
    :medium   =>    ['150x150>',     :jpg],
    :small    =>    ['30x30>',       :jpg]
  }

  has_attached_file :another_image, :styles => {
    :large    =>    ['350x350>',     :jpg],
    :medium   =>    ['150x150>',     :jpg],
    :small    =>    ['30x30>',       :jpg]
  }
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paperclip-dimension-0.1.0 spec/spec_helper.rb