Sha256: 88f733fbbcfe84b7c9d9be6ff50526b2affff3a08feb1388a0641d7022bf1be8

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe ::Rubiks::CalculatedMember 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?(:dimension) }
  specify { subject.respond_to?(:formula) }
  specify { subject.respond_to?(:format_string) }

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

    it { should be_valid }

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


    describe '#to_xml' do
      it 'renders a calculatedMember tag with attributes' do
        subject.to_xml.should be_like <<-XML
        <calculatedMember name="Fake Calculated Member" dimension="Fake Dimension" formula="fake_formula">
          <calculatedMemberProperty name="FORMAT_STRING" value="$#,##0.00"/>
        </calculatedMember>
        XML
      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 calculatedMember tag' do
        subject.to_xml.should be_like <<-XML
        <calculatedMember>
        </calculatedMember>
        XML
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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