Sha256: 8e1186245d5c93c17fdc639c9bea3521585cf82aeee018a414f55b97c60adedf

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Graphml2Json do
  let(:json) {'{"nodes":[{"name":0},{"name":1},{"name":2},{"name":3}],"edges":[{"source":0,"target":1},{"source":1,"target":2},{"source":2,"target":3},{"source":3,"target":null}]}'}

  describe '.generate' do
    context 'missing proper namespace' do
      it 'returns valid json' do
        graphml = File.read('spec/fixtures/graphml_without_namespacing.txt')
        Graphml2Json::generate(graphml).should == json
      end
    end

    context 'with namespace' do
      it 'returns valid json' do
        graphml = File.read('spec/fixtures/graphml_with_namespacing.txt')
        Graphml2Json::generate(graphml).should == json
      end
    end

    context 'with nodes' do
      let(:json){'{"nodes":[{"name":0,"color":"green"},{"name":1},{"name":2,"color":"blue"},{"name":3,"color":"red"},{"name":4},{"name":5,"color":"turquoise"}],"edges":[{"source":0,"target":2,"size":"1.0"},{"source":0,"target":1,"size":"1.0"},{"source":1,"target":3,"size":"2.0"},{"source":3,"target":2},{"source":2,"target":4},{"source":3,"target":5},{"source":5,"target":4,"size":"1.1"}]}'}

      it 'returns data as attributes' do
        graphml = File.read('spec/fixtures/attributes.graphml')
        Graphml2Json::generate(graphml).should == json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphml2json-0.1.1 spec/graphml2json_spec.rb
graphml2json-0.1.0 spec/graphml2json_spec.rb