Skip to content

Commit

Permalink
Add intensify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr1985 committed Feb 19, 2016
1 parent a7259d5 commit 8312c94
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/intensify_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

RSpec.describe Teaas::Intensify do
describe "#intensify" do
it "generates a intensified image" do
static_image = Magick::ImageList.new

static_image.from_blob(Base64.decode64("iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQAAAABbAUdZAAAABGdBTUEAALGP\nC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3Cc\nulE8AAAAAmJLR0QAAd2KE6QAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElN\nRQfgAgUQIQbuVAHWAAAAD0lEQVQI12P4DwQMg5cAANrpf4GXVFCUAAAAJXRF\nWHRkYXRlOmNyZWF0ZQAyMDE2LTAyLTA1VDE2OjMzOjA2LTA2OjAw2bi0+gAA\nACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wMi0wNVQxNjozMzowNi0wNjowMKjl\nDEYAAAAASUVORK5CYII=\n"))

flattened_static_image = static_image.flatten_images
intensified_image = double()

expect(Magick::ImageList).to receive(:new).and_return(intensified_image).twice

expect(static_image).to receive(:[]).and_return(flattened_static_image)

expect(intensified_image).to receive(:<<).exactly(7).times

Teaas::Intensify.intensify(static_image)
end
end

describe("#intensify_from_file") do
it "calls intensify with image" do
image = Magick::Image.new(32, 32)
expect(Magick::Image).to receive(:read).and_return(image)

expect(Teaas::Intensify).to receive(:intensify).with(image)
Teaas::Intensify.intensify_from_file("hello.png")
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'base64'
require 'rmagick'
require_relative '../lib/teaas/helper'
require_relative '../lib/teaas/intensify'
require_relative '../lib/teaas/marquee'
require_relative '../lib/teaas/spin'
require_relative '../lib/teaas/turboize'

0 comments on commit 8312c94

Please sign in to comment.