Sha256: 939354903157d172171d93806de738421cf01d45508628b9e9fed7dfad7be347

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 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'

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

3 entries across 3 versions & 1 rubygems

Version Path
imgkit-1.5.0 spec/spec_helper.rb
imgkit-1.4.2 spec/spec_helper.rb
imgkit-1.4.1 spec/spec_helper.rb