Sha256: dc7ec4be44cd21e354cf1c2a2a42f5b770e4ddd9bc7a417dff769c691e779867

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header)     { Relation::Header.coerce([ [ :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_instance_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_instance_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_instance_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
axiom-0.1.0 spec/unit/axiom/tuple/extend_spec.rb