Sha256: e9a4dc32e77afe4dbed69bed7aeb2b59114a36ffedb47b7aed609fabaf9fe5e5

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

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

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

    before do
      subject.should be_a(Alf::Operator::NonRelational::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

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-shell/operator/test_sort.rb
alf-0.12.1 spec/unit/alf-shell/operator/test_sort.rb
alf-0.12.0 spec/unit/alf-shell/operator/test_sort.rb
alf-0.11.1 spec/unit/alf-shell/operator/test_sort.rb
alf-0.11.0 spec/unit/alf-shell/operator/test_sort.rb