Sha256: 14db7d6ede745b69cc121a430c1cc0ba0c4a1d9159f0976e4a45cee81b178079

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

  before do
    described_class.class_eval do
      include Relation::Proxy

      def initialize(relation)
        @relation = relation
      end
    end
  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(body)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/relation/proxy/each_spec.rb