Sha256: 9e6a4ed3eecd08a0a03e0efd91e8f2c75a742d8e957973afca8ecbab4676a192

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

SPEC_ROOT = File.dirname(__FILE__)
$LOAD_PATH.unshift(SPEC_ROOT)
$LOAD_PATH.unshift(File.join(SPEC_ROOT, '..', 'lib'))
require 'imgkit'
require 'rspec'
require 'rspec/autorun'
require 'mocha'
require 'rack'
require 'tempfile'

RSpec.configure do |config|
  config.before do
    IMGKit.any_instance.stubs(:wkhtmltoimage).returns(
      File.join(SPEC_ROOT,'..','bin','wkhtmltoimage-proxy')
    )
  end
end

module MagicNumber
  extend self
  JPG  = "\xFF\xD8\xFF\xE0"
  JPEG = JPG
  PNG  = "\x89\x50\x4e\x47"
  TIFF = "\x49\x49\x2a\x00"
  TIF  = TIFF
  GIF  = "\x47\x49\x46\x38"


  if "".respond_to?(:force_encoding) 
    constants.each { |c| const_get(c).force_encoding("ASCII-8BIT")  }
  end

  def read(string)
    string[0,4]
  end
end

RSpec::Matchers.define :be_a do |expected|
  match do |actual|
    @expected = MagicNumber.const_get(expected.to_s.upcase)
    MagicNumber.read(actual) == @expected
  end

  failure_message_for_should do |actual|
    actual = MagicNumber.read(actual)
    "expctected #{actual.inspect},#{actual.encoding} to equal #{@expected.inspect},#{@expected.encoding}"
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
imgkit-1.4.0 spec/spec_helper.rb
imgkit-1.3.10 spec/spec_helper.rb
img-kit-1.3.9.1 spec/spec_helper.rb
imgkit-1.3.9 spec/spec_helper.rb
imgkit-1.3.8 spec/spec_helper.rb
imgkit-1.3.7 spec/spec_helper.rb
imgkit-1.3.6 spec/spec_helper.rb
imgkit-1.3.5 spec/spec_helper.rb
imgkit-1.3.4 spec/spec_helper.rb
imgkit-1.3.3 spec/spec_helper.rb
imgkit-1.3.2 spec/spec_helper.rb
imgkit-1.3.1 spec/spec_helper.rb
imgkit-1.3.0 spec/spec_helper.rb