Sha256: 41c44a47477ba1811a85e63b78e49967d16ef75978778b8a7db0d5c5c2180225

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:object) { described_class.new(header, body)           }
  let(:header) { [ [ :id, Integer ] ]                        }
  let(:body)   { LazyEnumerable.new([ [ 1 ], [ 2 ], [ 2 ] ]) }
  let(:yields) { []                                          }

  before do
    object.should be_instance_of(described_class)
  end

  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' do
    expect { subject }.to change { yields.dup }.
      from([]).
      to([ [ 1 ], [ 2 ] ])
  end
end

describe Relation do
  subject { object.new(header, body) }

  let(:header) { [ [ :id, Integer ] ]          }
  let(:body)   { LazyEnumerable.new([ [ 1 ] ]) }
  let(:object) { described_class               }

  before do
    subject.should be_instance_of(object)
  end

  it { should be_kind_of(Enumerable) }

  it 'case matches Enumerable' do
    (Enumerable === subject).should be(true)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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