Sha256: 0c96edbbb3dd6ec9ef8587b01e331d8764cf3afef427d3be875fdc84049d14a2

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require_relative "../../lib/middleman-imageoptim/optimizer"

describe Middleman::Imageoptim::Optimizer do
  subject(:optimizer) { Middleman::Imageoptim::Optimizer.new(app, builder, options) }
  let(:options) { Middleman::Imageoptim::Options.new() }
  let(:app) { double }
  let(:builder) { double }
  let(:size_src) { 1000 }
  let(:size_dst) { 1000 }

  describe "#size_change_word" do
    subject { optimizer.size_change_word(size_src, size_dst) }

    context "the destination file is the same size as the source file" do
      it "should be the same size" do
        subject.should == 'no change'
      end
    end

    context "the destination file is smaller" do
      let(:size_dst) { 500 }
      it "should be smaller" do
        subject.should == 'smaller'
      end
    end

    context "the destination file is larger" do
      let(:size_dst) { 1500 }
      it "should be larger" do
        subject.should == 'larger'
      end
    end
  end

  describe "#percentage_change" do
    subject { optimizer.percentage_change(size_src, size_dst) }

    context "the destination file is the same size as the source file" do
      it "should be the same size" do
        subject.should == "0.00%"
      end
    end

    context "the destination file is smaller" do
      let(:size_dst) { 500 }
      it "should be smaller" do
        subject.should == "50.00%"
      end
    end

    context "the destination file is larger" do
      let(:size_dst) { 1500 }
      it "should be larger" do
        subject.should == '-50.00%'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
middleman-imageoptim-0.1.4 spec/unit/optimizer_spec.rb
middleman-imageoptim-0.1.3 spec/unit/optimizer_spec.rb
middleman-imageoptim-0.1.2 spec/unit/optimizer_spec.rb
middleman-imageoptim-0.1.1 spec/unit/optimizer_spec.rb
middleman-imageoptim-0.1.0 spec/unit/optimizer_spec.rb