Sha256: 15d4ff8cc8379165c48abffe73f345847e3df42eb8f037631f5861ee2e1b37b6

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe ::Rubiks::Hierarchy do
  include_context 'schema_context'

  subject { described_class.new_from_hash }

  specify { subject.respond_to?(:from_hash) }
  specify { subject.respond_to?(:to_hash) }
  specify { subject.respond_to?(:levels) }

  context 'when parsed from a valid hash' do
    subject { described_class.new_from_hash(hierarchy_hash) }

    its(:to_hash) { should have_key('levels') }
    its(:to_hash) { should have_key('name') }
    its(:to_hash) { should have_key('dimension') }

    it { should be_valid }

    describe '#to_xml' do
      it 'renders a hierarchy tag with attributes' do
        subject.to_xml.should include(%Q!<hierarchy name="Fake Hierarchy" primaryKey="id" hasAll="true">!)
      end

      it 'renders a table tag with attributes' do
        subject.to_xml.should include(%Q!<table name="view_fake_dimensions"/>!)
      end
    end
  end

  context 'when parsed from an invalid (empty) hash' do
    subject { described_class.new_from_hash({}) }

    it { should_not be_valid }

    describe '#to_xml' do
      it 'renders a hierarchy and table tag' do
        subject.to_xml.should be_like <<-XML
        <hierarchy primaryKey="id" hasAll="true">
        <table/>
        </hierarchy>
        XML
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubiks-0.0.6 spec/rubiks/nodes/hierarchy_spec.rb
rubiks-0.0.5 spec/rubiks/nodes/hierarchy_spec.rb