Sha256: 04dc90c60b0b44e57bd76d71e8f4d17bda795b5506569bc01155c79737680f48

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe Gush::Graph do
  subject { described_class.new(TestWorkflow.create) }
  let(:filename) { "graph.png" }

  describe "#viz" do
    it "runs GraphViz to render graph" do
      node = double("node", :[]= => true)
      edge = double("edge", :[]= => true)
      graph = double("graph", node: node, edge: edge)
      path = Pathname.new(Dir.tmpdir).join(filename)
      expect(graph).to receive(:start).with(shape: 'diamond', fillcolor: '#CFF09E')
      expect(graph).to receive(:end).with(shape: 'diamond', fillcolor: '#F56991')

      expect(graph).to receive(:output).with(png: path.to_s)

      expect(graph).to receive(:add_nodes).with(/Prepare/, label: "Prepare")
      expect(graph).to receive(:add_nodes).with(/FetchFirstJob/, label: "FetchFirstJob")
      expect(graph).to receive(:add_nodes).with(/FetchSecondJob/, label: "FetchSecondJob")
      expect(graph).to receive(:add_nodes).with(/NormalizeJob/, label: "NormalizeJob")
      expect(graph).to receive(:add_nodes).with(/PersistFirstJob/, label: "PersistFirstJob")

      expect(graph).to receive(:add_edges).with(nil, /Prepare/)
      expect(graph).to receive(:add_edges).with(/Prepare/, /FetchFirstJob/)
      expect(graph).to receive(:add_edges).with(/Prepare/, /FetchSecondJob/)
      expect(graph).to receive(:add_edges).with(/FetchFirstJob/, /PersistFirstJob/)
      expect(graph).to receive(:add_edges).with(/FetchSecondJob/, /NormalizeJob/)
      expect(graph).to receive(:add_edges).with(/PersistFirstJob/, /NormalizeJob/)
      expect(graph).to receive(:add_edges).with(/NormalizeJob/, nil)

      expect(GraphViz).to receive(:new).and_yield(graph)

      subject.viz
    end
  end

  describe "#path" do
    it "returns string path to the rendered graph" do
      expect(subject.path).to eq(Pathname.new(Dir.tmpdir).join(filename).to_s)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
gush-2.0.2 spec/gush/graph_spec.rb
gush-2.0.1 spec/gush/graph_spec.rb
gush-2.0.0 spec/gush/graph_spec.rb
gush-1.1.1 spec/gush/graph_spec.rb
gush-1.1.0 spec/gush/graph_spec.rb
gush-1.0.0 spec/gush/graph_spec.rb
gush-mmx-0.4.2 spec/gush/graph_spec.rb
gush-0.4.1 spec/gush/graph_spec.rb
gush-0.3.3 spec/gush/graph_spec.rb
gush-0.4 spec/gush/graph_spec.rb
gush-0.3.2 spec/gush/graph_spec.rb
gush-0.3.1 spec/gush/graph_spec.rb