From 8312c946b1e21c80f906428d3c5f54fffe811f55 Mon Sep 17 00:00:00 2001 From: Bill Rastello Date: Fri, 19 Feb 2016 16:21:32 -0600 Subject: [PATCH] Add intensify tests --- spec/intensify_spec.rb | 32 ++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 1 + 2 files changed, 33 insertions(+) create mode 100644 spec/intensify_spec.rb diff --git a/spec/intensify_spec.rb b/spec/intensify_spec.rb new file mode 100644 index 0000000..cbfa105 --- /dev/null +++ b/spec/intensify_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 963e96b..6f5a962 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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'