Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move scoping into module wrappers inside spec. closes #4

  • Loading branch information...
commit e732170d85eea7bc409e07d0348433b96706fdf3 1 parent d0bd62c
@D4L authored
View
48 spec/abstract_graph/composition/edge/initialize_spec.rb
@@ -1,35 +1,39 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Edge do
+module AbstractGraph
+ module Composition
+ describe Edge do
- before :all do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- @v1 = AbstractGraph::Composition::Vertex.new "v1"
- @v2 = AbstractGraph::Composition::Vertex.new "v2"
- end
+ before :all do
+ Vertex.class_variable_set :@@names, []
+ @v1 = Vertex.new "v1"
+ @v2 = Vertex.new "v2"
+ end
- describe "#new(Vertex, Vertex)" do
+ describe "#new(Vertex, Vertex)" do
- before :each do
- @edge = AbstractGraph::Composition::Edge.new( @v1, @v2 )
- end
+ before :each do
+ @edge = Edge.new( @v1, @v2 )
+ end
- it "returns an object of class Edge" do
- @edge.should be_an_instance_of(AbstractGraph::Composition::Edge)
- end
+ it "returns an object of class Edge" do
+ @edge.should be_an_instance_of(Edge)
+ end
- end
+ end
- describe "#new(String, Vertex, Vertex)" do
+ describe "#new(String, Vertex, Vertex)" do
- before :each do
- @edge = AbstractGraph::Composition::Edge.new("e1", @v1, @v2)
- end
+ before :each do
+ @edge = Edge.new("e1", @v1, @v2)
+ end
- it "allows vertices to be initiated with a string name" do
- @edge.should_not be_nil
- end
+ it "allows vertices to be initiated with a string name" do
+ @edge.should_not be_nil
+ end
- end
+ end
+ end
+ end
end
View
76 spec/abstract_graph/composition/edge/name_spec.rb
@@ -1,50 +1,54 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Edge do
+module AbstractGraph
+ module Composition
+ describe Edge do
- before :all do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- @v1 = AbstractGraph::Composition::Vertex.new "v1"
- @v2 = AbstractGraph::Composition::Vertex.new "v2"
- end
-
- describe "#name" do
+ before :all do
+ Vertex.class_variable_set :@@names, []
+ @v1 = Vertex.new "v1"
+ @v2 = Vertex.new "v2"
+ end
- before :each do
- @arbitraryString = "arbitraryString"
- @edge = AbstractGraph::Composition::Edge.new @arbitraryString, @v1, @v2
- end
-
- it "returns a String (Always)" do
- @edge.name.should be_an_instance_of(String)
- end
+ describe "#name" do
- it "equals to the String in #new(String)" do
- @edge.name.should eql(@arbitraryString)
- end
+ before :each do
+ @arbitraryString = "arbitraryString"
+ @edge = Edge.new @arbitraryString, @v1, @v2
+ end
- it "equals to empty string if no string was passed in" do
- edge1 = AbstractGraph::Composition::Edge.new @v1, @v2
- edge1.name.should eql("")
- end
+ it "returns a String (Always)" do
+ @edge.name.should be_an_instance_of(String)
+ end
- end
+ it "equals to the String in #new(String)" do
+ @edge.name.should eql(@arbitraryString)
+ end
- describe "#name=" do
+ it "equals to empty string if no string was passed in" do
+ edge1 = Edge.new @v1, @v2
+ edge1.name.should eql("")
+ end
- before :each do
- @edge = AbstractGraph::Composition::Edge.new @v1, @v2
- end
+ end
- it "names the edge and retrieved by #name" do
- @edge.name = "Hello World"
- @edge.name.should eql("Hello World")
- end
+ describe "#name=" do
- it "doesn't allow a non-String input" do
- expect { @edge.name = 100 }.to raise_error
- end
+ before :each do
+ @edge = Edge.new @v1, @v2
+ end
- end
+ it "names the edge and retrieved by #name" do
+ @edge.name = "Hello World"
+ @edge.name.should eql("Hello World")
+ end
+
+ it "doesn't allow a non-String input" do
+ expect { @edge.name = 100 }.to raise_error
+ end
+ end
+
+ end
+ end
end
View
42 spec/abstract_graph/composition/edge/vertices_spec.rb
@@ -1,29 +1,33 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Edge do
+module AbstractGraph
+ module Composition
+ describe Edge do
- before :all do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- @v1 = AbstractGraph::Composition::Vertex.new "v1"
- @v2 = AbstractGraph::Composition::Vertex.new "v2"
- @edge = AbstractGraph::Composition::Edge.new( @v1, @v2 )
- end
+ before :all do
+ Vertex.class_variable_set :@@names, []
+ @v1 = Vertex.new "v1"
+ @v2 = Vertex.new "v2"
+ @edge = Edge.new( @v1, @v2 )
+ end
- describe "#vertices" do
+ describe "#vertices" do
- it "should be an enumerable" do
- @edge.vertices.should be_an_instance_of(Array)
- end
+ it "should be an enumerable" do
+ @edge.vertices.should be_an_instance_of(Array)
+ end
- it "must be two vertices" do
- @edge.vertices.should have(2).vertices
- end
+ it "must be two vertices" do
+ @edge.vertices.should have(2).vertices
+ end
- it "is the vertices passed from constructor" do
- @edge.vertices.should include( @v1 )
- @edge.vertices.should include( @v2 )
- end
+ it "is the vertices passed from constructor" do
+ @edge.vertices.should include( @v1 )
+ @edge.vertices.should include( @v2 )
+ end
- end
+ end
+ end
+ end
end
View
6 spec/abstract_graph/composition/edge_spec.rb
@@ -1,4 +1,8 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Edge do
+module AbstractGraph
+ module Composition
+ describe Edge do
+ end
+ end
end
View
24 spec/abstract_graph/composition/vertex/delete_spec.rb
@@ -1,18 +1,22 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Vertex do
+module AbstractGraph
+ module Composition
+ describe Vertex do
- before :each do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- end
+ before :each do
+ Vertex.class_variable_set :@@names, []
+ end
- describe "#delete" do
+ describe "#delete" do
- it "removes the name of the vertex in the namespace" do
- vertex = AbstractGraph::Composition::Vertex.new("v1")
- vertex.delete
- AbstractGraph::Composition::Vertex.class_variable_get(:@@names).should eql([])
- end
+ it "removes the name of the vertex in the namespace" do
+ vertex = Vertex.new("v1")
+ vertex.delete
+ Vertex.class_variable_get(:@@names).should eql([])
+ end
+ end
+ end
end
end
View
66 spec/abstract_graph/composition/vertex/initialize_spec.rb
@@ -1,49 +1,53 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Vertex do
+module AbstractGraph
+ module Composition
+ describe Vertex do
- before :each do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- end
+ before :each do
+ Vertex.class_variable_set :@@names, []
+ end
- describe "#new" do
+ describe "#new" do
- before (:each) do
- @vertex = AbstractGraph::Composition::Vertex.new
- end
+ before (:each) do
+ @vertex = Vertex.new
+ end
- it "returns an object of class Vertex" do
- @vertex.should be_an_instance_of(AbstractGraph::Composition::Vertex)
- end
+ it "returns an object of class Vertex" do
+ @vertex.should be_an_instance_of(Vertex)
+ end
- end
+ end
- describe "#new(String)" do
+ describe "#new(String)" do
- before (:each) do
- @vertex = AbstractGraph::Composition::Vertex.new("v1")
- end
+ before (:each) do
+ @vertex = Vertex.new("v1")
+ end
- it "allows vertices to be initiated with a string name" do
- @vertex.should_not be_nil
- end
+ it "allows vertices to be initiated with a string name" do
+ @vertex.should_not be_nil
+ end
- it "doesn't allow two vertices to be named the same" do
- expect { AbstractGraph::Composition::Vertex.new("v1") }.to raise_error
- end
+ it "doesn't allow two vertices to be named the same" do
+ expect { Vertex.new("v1") }.to raise_error
+ end
- end
+ end
- describe "#new(String, Object)" do
+ describe "#new(String, Object)" do
- before (:each) do
- @vertex = AbstractGraph::Composition::Vertex.new("v1", "Hello")
- end
+ before (:each) do
+ @vertex = Vertex.new("v1", "Hello")
+ end
- it "allows vertices to be initiated with name and value" do
- @vertex.should_not be_nil
- end
+ it "allows vertices to be initiated with name and value" do
+ @vertex.should_not be_nil
+ end
- end
+ end
+ end
+ end
end
View
118 spec/abstract_graph/composition/vertex/name_spec.rb
@@ -1,72 +1,76 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Vertex do
+module AbstractGraph
+ module Composition
+ describe Vertex do
- before :each do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- end
-
- describe "#name" do
-
- before (:each) do
- @arbitraryString = "abitraryString"
- @vertex = AbstractGraph::Composition::Vertex.new(@arbitraryString)
- end
-
- it "returns a String (Always)" do
- @vertex.name.should be_an_instance_of(String)
- end
-
- it "equals to the String in #new(String)" do
- @vertex.name.should eql(@arbitraryString)
- end
-
- it "equals to \"\" if nothing was passed as first param" do
- @vertex2 = AbstractGraph::Composition::Vertex.new()
- @vertex2.name.should eql("")
- end
+ before :each do
+ Vertex.class_variable_set :@@names, []
+ end
- end
+ describe "#name" do
- describe "#name=" do
+ before (:each) do
+ @arbitraryString = "abitraryString"
+ @vertex = Vertex.new(@arbitraryString)
+ end
- before (:each) do
- @vertex = AbstractGraph::Composition::Vertex.new()
- end
-
- it "names the vertex and retrieved by #name" do
- @vertex.name = "Hello World"
- @vertex.name.should eql("Hello World")
- end
+ it "returns a String (Always)" do
+ @vertex.name.should be_an_instance_of(String)
+ end
- it "doesn't allow a non-String input" do
- expect { @vertex.name = 100 }.to raise_error
- end
+ it "equals to the String in #new(String)" do
+ @vertex.name.should eql(@arbitraryString)
+ end
- it "doesn't allow two objects to have the same name" do
- @vertex.name = "v1"
- vertex2 = AbstractGraph::Composition::Vertex.new("v2")
- expect { vertex2.name = "v1" }.to raise_error
- end
+ it "equals to \"\" if nothing was passed as first param" do
+ @vertex2 = Vertex.new()
+ @vertex2.name.should eql("")
+ end
- it "can change a name of a vertex to free up the name" do
- @vertex.name = "v1"
- begin
- vertex2 = AbstractGraph::Composition::Vertex.new()
- rescue Exception => e
- fail
end
- end
- it "can reuse a name after delete removes it" do
- @vertex.name = "v1"
- @vertex.delete
- begin
- vertex2 = AbstractGraph::Composition::Vertex.new("v1")
- rescue Exception => e
- fail
+ describe "#name=" do
+
+ before (:each) do
+ @vertex = Vertex.new()
+ end
+
+ it "names the vertex and retrieved by #name" do
+ @vertex.name = "Hello World"
+ @vertex.name.should eql("Hello World")
+ end
+
+ it "doesn't allow a non-String input" do
+ expect { @vertex.name = 100 }.to raise_error
+ end
+
+ it "doesn't allow two objects to have the same name" do
+ @vertex.name = "v1"
+ vertex2 = Vertex.new("v2")
+ expect { vertex2.name = "v1" }.to raise_error
+ end
+
+ it "can change a name of a vertex to free up the name" do
+ @vertex.name = "v1"
+ begin
+ vertex2 = Vertex.new()
+ rescue Exception => e
+ fail
+ end
+ end
+
+ it "can reuse a name after delete removes it" do
+ @vertex.name = "v1"
+ @vertex.delete
+ begin
+ vertex2 = Vertex.new("v1")
+ rescue Exception => e
+ fail
+ end
+ end
+
end
end
-
end
end
View
66 spec/abstract_graph/composition/vertex/value_spec.rb
@@ -1,46 +1,50 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Vertex do
+module AbstractGraph
+ module Composition
+ describe Vertex do
- before :each do
- AbstractGraph::Composition::Vertex.class_variable_set :@@names, []
- end
+ before :each do
+ Vertex.class_variable_set :@@names, []
+ end
- describe "#value" do
+ describe "#value" do
- before (:each) do
- @arbitraryString = "arbitraryString"
- @arbitraryObject = Object.new
- end
+ before (:each) do
+ @arbitraryString = "arbitraryString"
+ @arbitraryObject = Object.new
+ end
- it "equals the object passed in #new(String, Object)" do
- vertex = AbstractGraph::Composition::Vertex.new(@arbitraryString, @arbitraryObject)
- vertex.value.should eql(@arbitraryObject)
- end
+ it "equals the object passed in #new(String, Object)" do
+ vertex = Vertex.new(@arbitraryString, @arbitraryObject)
+ vertex.value.should eql(@arbitraryObject)
+ end
- it "equals to nil if nothing was passed as second param" do
- vertex = AbstractGraph::Composition::Vertex.new()
- vertex.value.should be_nil
- end
+ it "equals to nil if nothing was passed as second param" do
+ vertex = Vertex.new()
+ vertex.value.should be_nil
+ end
- end
+ end
- describe "#value=" do
+ describe "#value=" do
- before (:each) do
- @vertex = AbstractGraph::Composition::Vertex.new()
- end
+ before (:each) do
+ @vertex = Vertex.new()
+ end
- it "allows us to change the value of the vertex" do
- @vertex.value = 2
- @vertex.value.should eql(2)
- end
+ it "allows us to change the value of the vertex" do
+ @vertex.value = 2
+ @vertex.value.should eql(2)
+ end
- it "allows us to create two vertices of the same object" do
- @vertex.value = "Hello"
- @vertex2 = AbstractGraph::Composition::Vertex.new("v2", "Hello")
- @vertex.value.should eql(@vertex2.value)
- end
+ it "allows us to create two vertices of the same object" do
+ @vertex.value = "Hello"
+ @vertex2 = Vertex.new("v2", "Hello")
+ @vertex.value.should eql(@vertex2.value)
+ end
+ end
+ end
end
end
View
6 spec/abstract_graph/composition/vertex_spec.rb
@@ -1,4 +1,8 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Vertex do
+module AbstractGraph
+ module Composition
+ describe Vertex do
+ end
+ end
end
View
18 spec/abstract_graph/graph/intialize_spec.rb
@@ -1,15 +1,17 @@
require 'spec_helper'
-describe AbstractGraph::Graph do
- describe "#new" do
+module AbstractGraph
+ describe Graph do
+ describe "#new" do
- before(:each) do
- @graph = AbstractGraph::Graph.new
- end
+ before(:each) do
+ @graph = Graph.new
+ end
- it "returns an object of class Graph" do
- @graph.class.should == AbstractGraph::Graph
- end
+ it "returns an object of class Graph" do
+ @graph.class.should == Graph
+ end
+ end
end
end
View
4 spec/abstract_graph/graph_spec.rb
@@ -1,4 +1,6 @@
require 'spec_helper'
-describe AbstractGraph::Graph do
+module AbstractGraph
+ describe Graph do
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.