Sha256: 3959c36ee8431b0953c1e9569bc51caf224af0c2a3923243cac30b6fe78ad1f3

Contents?: true

Size: 941 Bytes

Versions: 1

Compression:

Stored size: 941 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Relation::Operation::Order, '#each' do
  subject { object.each { |tuple| yields << tuple } }

  let(:object)     { described_class.new(relation, directions)                   }
  let(:relation)   { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ], [ 3 ] ]) }
  let(:directions) { [ relation[:id].desc ]                                      }
  let(:yields)     { []                                                          }

  it_should_behave_like 'an #each method'

  it 'yields only tuples' do
    subject
    yields.each { |tuple| tuple.should be_instance_of(Tuple) }
  end

  it 'yields only tuples with the expected header' do
    subject
    yields.each { |tuple| tuple.header.should be(object.header) }
  end

  it 'yields only tuples with the expected data in order' do
    expect { subject }.to change { yields.dup }.
      from([]).
      to([ [ 3 ], [ 2 ], [ 1 ] ])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/relation/operation/order/each_spec.rb