Sha256: 29e570a16183ec6ac02c3652c376bac2e93efb91b9c6e5c332fb4d58a3ab4ea7

Contents?: true

Size: 706 Bytes

Versions: 3

Compression:

Stored size: 706 Bytes

Contents

require 'spec_helper'

describe Kludge::Mishmash do
  class Tree < Kludge::Mishmash
    one :trunk
    many :branches, :belongs_to => :trunk
  end

  let(:trunk) { mock :trunk }
  let(:branch) { mock :branch }
  let(:branches) { [branch, branch] }
  let(:tree) { Tree.new(:trunk => trunk, :branches => branches) }

  it 'contains many parts' do
    Tree.parts.names.should eql([:trunk, :branches])
  end

  it 'defines parts as "many" or "one"' do
    expect(Tree.parts.select(&:many?).length).to eql(1)
    expect(Tree.parts.select(&:one?).length).to eql(1)
  end

  it 'defines accessor methods for each part' do
    expect(tree.trunk).to eql(trunk)
    expect(tree.branches).to eql(branches)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kludge-0.0.3 spec/kludge/mishmash_spec.rb
kludge-0.0.2 spec/kludge/mishmash_spec.rb
kludge-0.0.1 spec/kludge/mishmash_spec.rb