Sha256: 9f2c66a46bc2a8fcb60a7969e6f12098f124ddae7ad5a16c5ec95154a32ba212

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

require 'rubygems'
require 'bundler/setup'

require 'chunky_bits'

module ResourceFileHelper
  
  def resource_file(name)
    File.expand_path("./resources/#{name}", File.dirname(__FILE__))
  end
  
  def resource_data(name)
    data = nil
    File.open(resource_file(name), 'rb') { |f| data = f.read } 
    data
  end
  
  def reference_canvas(name)
    ChunkyPNG::Canvas.from_file(resource_file("#{name}.png"))
  end
  
  def reference_image(name)
    ChunkyPNG::Image.from_file(resource_file("#{name}.png"))
  end
  
  def display(png)
    filename = resource_file('_tmp.png')
    png.save(filename)
    `open #{filename}`
  end
end

RSpec.configure do |config|
  config.include ResourceFileHelper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chunky_bits-0.0.1 spec/spec_helper.rb