Sha256: 6634f1504b6904ae28ee66e361ef89be878a88fa6878c354488af29efda23989

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 Bytes

Contents

require 'spec_helper'
module Alf::Shell::Operator
  describe Restrict do

    let(:input){ suppliers }
    subject{ Restrict.run(argv) }

    before do
      subject.should be_a(Alf::Algebra::Restrict)
      subject.operands.should eq([input])
    end

    context "without arg" do
      let(:argv){ [input] }
      specify{
        subject.predicate.should eq(Alf::Predicate.coerce(true))
      }
    end

    context "with a single arg" do
      let(:argv){ [ input ] + ["--", "status > 10"] }
      specify{
        subject.predicate.should be_a(Alf::Predicate)
        subject.predicate.to_ruby_code.should eq("status > 10")
      }
    end

    context "with two args" do
      let(:argv){ [ input ] + ["--", "status", "10"] }
      specify{
        subject.predicate.should eq(Alf::Predicate.comp(:eq, :status => 10))
      }
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alf-shell-0.14.0 spec/unit/operator/test_restrict.rb
alf-shell-0.13.1 spec/unit/operator/test_restrict.rb
alf-shell-0.13.0 spec/unit/operator/test_restrict.rb