Permalink
Browse files

Move scoping into module wrappers inside spec. closes #4

  • Loading branch information...
D4L committed Dec 31, 2012
1 parent d0bd62c commit e732170d85eea7bc409e07d0348433b96706fdf3
@@ -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
@@ -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
@@ -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
@@ -1,4 +1,8 @@
require 'spec_helper'
-describe AbstractGraph::Composition::Edge do
+module AbstractGraph
+ module Composition
+ describe Edge do
+ end
+ end
end
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit e732170

Please sign in to comment.