Sha256: 74488a6bffd3d4036ad4e5698b2aa84d50b047572db1517cc5edb3cdb1a0097d

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
module Alf
  module Engine
    describe Take do

      it 'should work on an empty operand' do
        Take.new(Leaf.new([]), 1, 1).to_a.should eq([])
      end

      it 'should filter according to the offset' do
        rel = Leaf.new [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        exp = [
          {:name => "Smith"}
        ]
        Take.new(rel, 1, 10).to_a.should eq(exp)
      end

      it 'should filter according to the limit (1/2)' do
        rel = Leaf.new [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        exp = [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        Take.new(rel, 0, 2).to_a.should eq(exp)
      end

      it 'should filter according to the limit (2/2)' do
        rel = Leaf.new [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        exp = [
          {:name => "Jones"},
        ]
        Take.new(rel, 0, 1).to_a.should eq(exp)
      end

    end
  end # module Engine
end # module Alf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-engine/test_take.rb
alf-core-0.14.0 spec/unit/alf-engine/test_take.rb