Sha256: 90936049bd3e6566a15e779ad2ca0e81209c310d46cef367dd9b69034c4fb1f6

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
require 'rspec'
require 'image_optim/bin_resolver/comparable_condition'

describe ImageOptim::BinResolver::ComparableCondition do
  is = ImageOptim::BinResolver::ComparableCondition.is

  it 'should build 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 'should stringify 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 'should match 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

5 entries across 5 versions & 1 rubygems

Version Path
image_optim-0.17.1 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.17.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.16.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.15.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb
image_optim-0.14.0 spec/image_optim/bin_resolver/comparable_condition_spec.rb