/
delete_edge_spec.rb
56 lines (42 loc) · 1.29 KB
/
delete_edge_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'spec_helper'
module AbstractGraph
describe Graph do
before :all do
@vertex1 = "Vertex1"
@vertex2 = "Vertex2"
@edge = "MyEdge"
end
before :each do
@graph = Graph.new
@graph.add_vertex @vertex1
@graph.add_vertex @vertex2
@graph.add_edge @edge, @vertex1, @vertex2
end
describe "#delete_edge(String)" do
it "returns an object of class Graph" do
@graph.delete_edge( @edge ).should be_an_instance_of(Graph)
end
it "returns an object without the edge" do
nextGraph = @graph.delete_edge( @edge )
nextGraph.has_edge?( @edge ).should be_false
end
it "does not modify the original graph" do
@graph.delete_edge( @edge )
@graph.has_edge?( @edge ).should be_true
end
end
describe "#delete_edge!(String)" do
it "returns an object of class Graph" do
@graph.delete_edge!( @edge ).should be_an_instance_of(Graph)
end
it "returns an object without the edge" do
nextGraph = @graph.delete_edge!( @edge )
nextGraph.has_edge?( @edge ).should be_false
end
it "removes the edge from the original graph" do
@graph.delete_edge!( @edge )
@graph.has_edge?( @edge ).should be_false
end
end
end
end