Sha256: b1c0ea2ab5e45dc3bcdc5f49b5da74568c3244f759cfeb8df2abe23c3a88b4e7

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:object)   { described_class.new(order)                                  }
  let(:relation) { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ], [ 3 ] ]) }
  let(:order)    { relation.sort_by { |r| r.id }                               }
  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 reverse 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/reverse/each_spec.rb