Sha256: cb530bd0e7de59d2a752f47be8c7f5be75146876edb1a9f9c6ffeee7c480c72a

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 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('bundle exec wkhtmltoimage')
  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

4 entries across 4 versions & 1 rubygems

Version Path
imgkit-1.6.3 spec/spec_helper.rb
imgkit-1.6.2 spec/spec_helper.rb
imgkit-1.6.1 spec/spec_helper.rb
imgkit-1.6.0 spec/spec_helper.rb