DepGraph 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,103 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
- require 'graph_creator'
3
- require 'rubygems'
4
- gem 'filetesthelper'
5
- require 'spec'
6
- require 'filetesthelper'
7
- include DepGraph
8
- include FileTestHelper
9
-
10
- describe GraphCreator do
11
- it 'should not create a file if the graph is empty' do
12
- create_graph_creator_with_no_dependents.create_image.should be_false
13
- end
14
-
15
- it 'should return a nil graph if an empty set of dependents is specified' do
16
- create_graph_creator_with_no_dependents.create_graph.should == nil
17
- end
18
-
19
- it 'should return a nil graph if only one dependent is specified' do
20
- create_graph_creator_with_only_one_dependent.create_graph.should == nil
21
- end
22
-
23
- it 'should return a nil graph if all dependents specified are equal' do
24
- create_graph_creator_with_three_dependents_that_are_equal.create_graph.should == nil
25
- end
26
-
27
- it 'should return a graph with 2 nodes and no edges if 2 dependents with no dependencies are specified' do
28
- graph = create_graph_creator_with_two_dependents_and_no_dependencies.create_graph
29
-
30
- graph.node_count.should == 2
31
- graph.edge_count.should == 0
32
- end
33
-
34
- it 'should ignore dependencies to non existent dependents' do
35
- graph = create_graph_creator_with_two_nodes_and_one_orphan_dependency.create_graph
36
-
37
- graph.node_count.should == 2
38
- graph.edge_count.should == 0
39
- end
40
-
41
- it 'should return a graph with one edge if two dependents with one dependable are specified' do
42
- graph = create_graph_creator_with_two_nodes_and_one_dependency.create_graph
43
-
44
- graph.node_count.should == 2
45
- graph.edge_count.should == 1
46
- end
47
-
48
- it 'should be possible to filter dependents with a regular expression' do
49
- graph_creator = create_dependency_chain_graph_creator('node1', 'node2', 'node3', 'node4')
50
- graph_creator.from = 'e2$'
51
- graph = graph_creator.create_graph
52
-
53
- graph.node_count.should == 2
54
- graph.edge_count.should == 1
55
- graph.has_node?('node2').should be_true
56
- graph.has_node?('node3').should be_true
57
- graph.has_edge?('node2', 'node3').should be_true
58
- end
59
-
60
- it 'should be possible to filter dependables with a regular expression' do
61
- graph_creator = create_dependency_chain_graph_creator('node1', 'node2', 'node3', 'node4')
62
- graph_creator.to = 'e4$'
63
- graph = graph_creator.create_graph
64
-
65
- graph.node_count.should == 2
66
- graph.edge_count.should == 1
67
- graph.has_node?('node3').should be_true
68
- graph.has_node?('node4').should be_true
69
- graph.has_edge?('node3', 'node4').should be_true
70
- end
71
-
72
-
73
- invalid_graph_creators.each do |invalid_graph_creator_description, invalid_graph_creator|
74
- it "should return false when trying to create an image from a #{invalid_graph_creator_description}" do
75
- invalid_graph_creator.graph_class = NoOutputGraph
76
- invalid_graph_creator.create_image('graph.png').should be_false
77
- end
78
- end
79
- end
80
-
81
- test_data = {
82
- :csproj => {'file1.csproj'=>'"file2.csproj"', 'dir/file2.csproj'=>'"file1.csproj"' },
83
- :ruby_requires => {'file1.rb'=>'require "file2"', 'dir/file2.rb'=>'require "file1"' }
84
- }
85
-
86
- describe GraphCreator, '(integration tests)' do
87
- dependency_types.each do |filter_type|
88
- it "should create a png image from the #{filter_type} dependencies found in the current directory tree" do
89
- with_files(test_data[filter_type]) do
90
- GraphCreator.new(filter_type).create_image('test.png')
91
-
92
- non_empty_file_created('test.png').should be_true
93
- end
94
- end
95
- end
96
- end
97
-
98
-
99
-
100
-
101
-
102
-
103
-
data/spec/graph_spec.rb DELETED
@@ -1,120 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
- require 'graph'
3
- require 'rubygems'
4
- gem 'filetesthelper'
5
- require 'spec'
6
- require 'filetesthelper'
7
- include FileTestHelper
8
- include DepGraph
9
-
10
- def create_empty_graph
11
- Graph.new
12
- end
13
-
14
- def create_graph_with_2_nodes_and_1_edge
15
- graph = create_empty_graph
16
- graph.add_node('node 1')
17
- graph.add_node('node 2')
18
- graph.add_edge('node 1', 'node 2')
19
- return graph
20
- end
21
-
22
- def create_graph_with_2_nodes_and_0_edges
23
- graph = create_empty_graph
24
- graph.add_node('node 1')
25
- graph.add_node('node 2')
26
- return graph
27
- end
28
-
29
- def no_output_generation
30
- lambda {true}
31
- end
32
-
33
- describe Graph do
34
-
35
- it "should start with no nodes" do
36
- create_empty_graph.node_count.should == 0
37
- end
38
-
39
- it "should be possible to add nodes" do
40
- graph = create_graph_with_2_nodes_and_0_edges
41
-
42
- graph.node_count.should == 2
43
- graph.edge_count.should == 0
44
- end
45
-
46
- it "should not be allowed to add a node without a name" do
47
- lambda {create_empty_graph.add_node('')}.should raise_error
48
- end
49
-
50
- it "should start with no edges" do
51
- create_empty_graph.edge_count.should == 0
52
- end
53
-
54
- it "should be possible to add an edge" do
55
- graph = create_graph_with_2_nodes_and_1_edge
56
-
57
- graph.node_count.should == 2
58
- graph.edge_count.should == 1
59
- end
60
-
61
- it "can be reset" do
62
- graph = create_graph_with_2_nodes_and_1_edge
63
-
64
- graph.reset
65
- graph.node_count.should == 0
66
- graph.edge_count.should == 0
67
- end
68
-
69
- it "should not be allowed to add edges between non existent nodes" do
70
- lambda {create_empty_graph.add_edge('no node 1', 'no node 2')}.should raise_error
71
- end
72
-
73
- it "should return true when a new image file is created" do
74
- graph = create_graph_with_2_nodes_and_1_edge
75
- graph.output_generation = no_output_generation
76
- graph.create_image('graph.png').should be_true
77
- end
78
-
79
- it "should return false when trying to create an empty graph" do
80
- graph = create_empty_graph
81
- graph.output_generation = no_output_generation
82
- graph.create_image('graph.png').should be_false
83
- end
84
- end
85
-
86
- describe Graph, '(integration tests)' do
87
- it "should create a file with the graph image" do
88
- with_files do
89
- graph = create_graph_with_2_nodes_and_1_edge
90
- graph.create_image('graph.png')
91
-
92
- non_empty_file_created('graph.png').should be_true
93
- end
94
- end
95
-
96
- it "should not create an image file from an empty graph" do
97
- with_files do
98
- create_empty_graph.create_image('graph.png')
99
- non_empty_file_created('graph.png').should be_false
100
- end
101
- end
102
-
103
- it "should not create an image file from a graph with no edges" do
104
- with_files do
105
- create_graph_with_2_nodes_and_0_edges.create_image('graph.png')
106
-
107
- non_empty_file_created('graph.png').should be_false
108
- end
109
- end
110
-
111
- it 'can change output generation behaviour'do
112
- graph = create_graph_with_2_nodes_and_1_edge
113
- graph.output_generation = no_output_generation
114
- with_files do
115
- graph.create_image('test.png')
116
- File.exist?('test.png').should be_false
117
- end
118
- end
119
- end
120
-
data/todo.txt DELETED
@@ -1,4 +0,0 @@
1
- -Separate integration tests form unit tests
2
-
3
-
4
-