Sha256: 6aa91821b237228412903463799558eba537e379bcb5d05a3824dfbd6c3432e9

Contents?: true

Size: 1.88 KB

Versions: 14

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'
require 'geoff/children_dsl'

describe ChildrenDsl do
  before { stub_node_dsl_object_id }

  let(:starbucks_node_dsl) { mock node_name: 'starbucks' }

  describe 'with no special nodes' do
    let(:children) do
      ChildrenDsl.new({parent_node_dsl: starbucks_node_dsl}) 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_dsl: starbucks_node_dsl)           {area 'Luton' } }
    let(:top)    {ChildrenDsl.new(parent_node_dsl: starbucks_node_dsl, type: :x ){area 'Luton' } }
    let(:on_node){ChildrenDsl.new(parent_node_dsl: starbucks_node_dsl)           {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_dsl: starbucks_node_dsl}) 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

14 entries across 14 versions & 1 rubygems

Version Path
geoff-0.2.6 spec/integration/children_dsl_spec.rb
geoff-0.2.5 spec/integration/children_dsl_spec.rb
geoff-0.2.3 spec/integration/children_dsl_spec.rb
geoff-0.2.2 spec/integration/children_dsl_spec.rb
geoff-0.2.1 spec/integration/children_dsl_spec.rb
geoff-0.2.0 spec/integration/children_dsl_spec.rb
geoff-0.1.2 spec/integration/children_dsl_spec.rb
geoff-0.1.1 spec/integration/children_dsl_spec.rb
geoff-0.1.0 spec/integration/children_dsl_spec.rb
geoff-0.0.8 spec/integration/children_dsl_spec.rb
geoff-0.0.7 spec/integration/children_dsl_spec.rb
geoff-0.0.6 spec/integration/children_dsl_spec.rb
geoff-0.0.5 spec/integration/children_dsl_spec.rb
geoff-0.0.4 spec/integration/children_dsl_spec.rb