Sha256: 7da538e1fac4a47f771c5f6090a199088a681a174828e495aa11003bf92562f9

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

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

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

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

    context "with empty args" do
      let(:argv){ [input] + %w{} }
      specify{
        subject.ordering.should eq(Alf::Ordering.new([]))
      }
    end

    context "with one arg" do
      let(:argv){ [input] + %w{-- name} }
      specify{
        subject.ordering.should eq(Alf::Ordering[[:name, :asc]])
      }
    end

    context "with two args" do
      let(:argv){ [input] + %w{-- first last} }
      specify{
        subject.ordering.should eq(Alf::Ordering[[[:first, :asc], [:last, :asc]]])
      }
    end

    context "with explicit ordering" do
      let(:argv){ [input] + %w{-- first desc} }
      specify{
        subject.ordering.should eq(Alf::Ordering[[[:first, :desc]]])
      }
    end

    context "with explicit ordering on multiple" do
      let(:argv){ [input] + %w{-- first desc last asc} }
      specify{
        subject.ordering.should eq(Alf::Ordering[[[:first, :desc], [:last, :asc]]])
      }
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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