Sha256: a5fd6b1040064df11a677dd8be1f743d653d05070b2b03555ba6f5735cb972d4

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Tuple, '#extend' do
  subject { object.extend(new_header, extensions) }

  let(:header)     { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
  let(:new_header) { header | [ [ :test, Integer ] ]                               }
  let(:object)     { described_class.new(header, [ 1, 'Dan Kubb' ])                }

  context 'when the extension is a Proc' do
    let(:extensions) { [ lambda { |tuple| 1 } ] }

    it { should be_kind_of(described_class) }

    its(:header) { should equal(new_header) }

    its(:to_ary) { should == [ 1, 'Dan Kubb', 1 ] }
  end

  context 'when the extension is a Function' do
    let(:extensions) { [ header[:id].abs ] }

    it { should be_kind_of(described_class) }

    its(:header) { should equal(new_header) }

    its(:to_ary) { should == [ 1, 'Dan Kubb', 1 ] }
  end

  context 'when the extension is a value' do
    let(:extensions) { [ 1 ] }

    it { should be_kind_of(described_class) }

    its(:header) { should equal(new_header) }

    its(:to_ary) { should == [ 1, 'Dan Kubb', 1 ] }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/tuple/extend_spec.rb