Sha256: 46851b3511864aca30f99e79067ff658007967bdd27f16ca1a9911c583023f07

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe Gatling::Comparison do

  before do
    apple = Magick::Image.new(100,100) { self.background_color = "green" }
    orange = Magick::Image.new(100,100) { self.background_color = "orange" }
    @apple = Gatling::Image.new(apple, "apple.png")
    @orange = Gatling::Image.new(orange, "orange.png")
  end

  describe 'will compare two images' do

    it 'will return true if the images are identical' do
      Gatling::Comparison.new(@apple, @apple).matches?.should == true
    end

    it 'will return false if the images are different' do
      Gatling::Comparison.new(@orange, @apple).matches?.should == false
    end
  end

  describe 'Diff images' do
    describe 'for two images with the same size' do
      it 'will be generated' do
        Gatling::Comparison.new(@apple, @orange).diff_image.class.should == Gatling::Image
      end
    end

    describe 'for two images with different sizes' do
      before do
        @apple_image = Magick::Image.new(30,300) { self.background_color = "green" }
        @orange_image = Magick::Image.new(80,100) { self.background_color = "orange" }

        @apple = Gatling::Image.new(@apple_image, "apple.png")
        @orange = Gatling::Image.new(@orange_image, "orange.png")

        @diff_image = Gatling::Comparison.new(@apple, @orange).diff_image
      end

      it 'will be generated' do
        @diff_image.class.should == Gatling::Image
      end

      it 'will be extended to cover the difference in both images' do
        @diff_image.image.columns.should eql 80
        @diff_image.image.rows.should eql 300
      end

      describe 'with two different offset' do
        before do
          @apple_image.offset = 50
          @orange_image.offset = 2

          @diff_image = Gatling::Comparison.new(@apple, @orange).diff_image
        end

        it 'will remove image offset from the diff image' do
          @diff_image.image.offset.should eql 0
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gatling-1.1.3 spec/comparison_spec.rb