Sha256: 4e3904dcba3512aeb7a0389c7cc32390a616cb9d59bab5fb3f831ea2a055fcac

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path('spec/spec_helper')
require 'neo4j'
require 'geoff'

describe Geoff do
  class CoverageArea
    include Neo4j::NodeMixin
  end
  class Cafe
    include Neo4j::NodeMixin
  end

  class Carrier
    include Neo4j::NodeMixin
  end

  class Branch
    include Neo4j::NodeMixin
  end
  describe 'base nodes' do

    let(:builder) do
      Geoff(Cafe, Carrier, Branch, CoverageArea)
    end

    let(:expected_geoff) do
      strip_whitespace <<-EOS
        (ROOT)-[:Cafe]->(Cafe)
        (ROOT)-[:Carrier]->(Carrier)
        (ROOT)-[:Branch]->(Branch)
        (ROOT)-[:CoverageArea]->(CoverageArea)
      EOS
    end

    specify do
      builder.to_s.should == expected_geoff
    end
  end

  describe 'Geoff sugar' do
    let(:node) do
      Geoff(Branch) do
        branch 'starbucks_branch' do
          delay_time 15
        end
      end
    end

    let(:expected_geoff) do
      strip_whitespace <<-EOS
        (ROOT)-[:Branch]->(Branch)
        (starbucks_branch) {"_classname":"Branch","delay_time":15}
        (Branch)-[:all]->(starbucks_branch)
      EOS
    end

    specify do
      node.to_geoff.should == expected_geoff
    end

    specify do
      pending 'not implemented'
      ->{
        Geoff do
          branch 'starbucks_branch' do
            delay_time 15
          end
        end
      }.should raise_error Geoff::MissingClassDefinition, "branch"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geoff-0.0.3.beta spec/models/geoff_spec.rb
geoff-0.0.2.beta spec/models/geoff_spec.rb