Sha256: e9ae74e3b1ee0bf076e792bc1453a782c83de6f7f8732142d41deb0df4f67cea

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'image_optim/bin_resolver/comparable_condition'

describe ImageOptim::BinResolver::ComparableCondition do
  let(:is){ ImageOptim::BinResolver::ComparableCondition.is }

  it 'builds conditions' do
    expect(is.between?(10, 20).method).to eq(:between?)
    expect(is.between?(10, 20).args).to eq([10, 20])

    expect((is >= 15).method).to eq(:>=)
    expect((is >= 15).args).to eq([15])

    expect((is < 30).method).to eq(:<)
    expect((is < 30).args).to eq([30])
  end

  it 'stringifies conditions' do
    expect(is.between?(10, 20).to_s).to eq('10..20')
    expect((is >= 15).to_s).to eq('>= 15')
    expect((is < 30).to_s).to eq('< 30')
  end

  it 'matches conditions' do
    expect(is.between?(10, 20)).not_to match 9
    expect(is.between?(10, 20)).to match 15
    expect(is.between?(10, 20)).not_to match 21

    expect(is >= 15).not_to match 14
    expect(is >= 15).to match 15
    expect(is >= 15).to match 16

    expect(is < 30).to match 29
    expect(is < 30).not_to match 30
    expect(is < 30).not_to match 31
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
image_optim-0.31.4 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.31.3 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.31.2 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.31.1 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.31.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.30.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.29.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.28.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.27.1 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.27.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.26.5 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.26.4 spec/image_optim/bin_resolver/comparable_condition_spec.rb