Sha256: d6c850701123c8347774cb1a5318405547c5f769a2a563074755b73b221a81f0

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 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 make images from ' do

  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

4 entries across 4 versions & 1 rubygems

Version Path
gatling-1.1.2 spec/comparison_spec.rb
gatling-1.1.1 spec/comparison_spec.rb
gatling-1.1.0 spec/comparison_spec.rb
gatling-1.0.9 spec/comparison_spec.rb