Sha256: 4ce6f7ca65eec8e7f866e69a410f237f4b9549b406dbb54ee92f96f3d3b836a4

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'
require 'geoff/children_dsl'

describe ChildrenDsl do
  describe 'with no special nodes' do
    let(:children) do
      ChildrenDsl.new({parent_node_name: 'starbucks'}) do
        branch 'starbucks_branch_1', type: 'owns' do
          delay_time 15
        end

        branch 'starbucks_branch_2', type: 'owns' do
          delay_time 30
        end
      end
    end

    let(:expected_geoff) do
      strip_whitespace <<-EOS
        (starbucks_branch_1) {"_classname":"Branch","delay_time":15}
        (Branch)-[:all]->(starbucks_branch_1)
        (starbucks)-[:owns]->(starbucks_branch_1)
        (starbucks_branch_2) {"_classname":"Branch","delay_time":30}
        (Branch)-[:all]->(starbucks_branch_2)
        (starbucks)-[:owns]->(starbucks_branch_2)
      EOS
    end

    specify do
      geoff = children.to_geoff

      geoff.should == expected_geoff
    end
  end

  context "with missing rel type" do
    let(:missing){ChildrenDsl.new(parent_node_name: 'starbucks')           {area 'Luton' } }
    let(:top)    {ChildrenDsl.new(parent_node_name: 'starbucks', type: :x ){area 'Luton' } }
    let(:on_node){ChildrenDsl.new(parent_node_name: 'starbucks')           {area 'Luton', type: :x }}

    specify { ->{missing }.should     raise_error Geoff::DslSyntaxError}
    specify { ->{ top    }.should_not raise_error  }
    specify { ->{ on_node}.should_not raise_error  }
  end

  describe 'with special node' do
    let(:children) do
      ChildrenDsl.new({parent_node_name: 'starbucks'}) do
        b.luton = area 'Luton', type: 'headquarters_location' do
          name 'LU1'
        end
      end
    end

    specify do
      luton = children.b.luton

      luton.node_name.should      == 'Luton'
      luton.name.should           == 'LU1'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geoff-0.0.3.beta spec/integration/children_dsl_spec.rb