From e2bfe13863188f286cdfda010aac750591a7e027 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 18 Jul 2012 09:31:29 +0100 Subject: [PATCH] Added SimpleCov, added tests for Vertex#to_s and Edge#to_s --- .gitignore | 3 +++ Gemfile | 7 ++++--- Gemfile.lock | 32 +++++++++++++++++++------------- lib/graph.njae/vertex.rb | 2 +- spec/graph/edge_spec.rb | 10 ++++++++++ spec/graph/vertex_spec.rb | 8 ++++++++ spec/spec_helper.rb | 14 +++----------- 7 files changed, 48 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 63a685e..094d694 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ doc # jeweler generated pkg +# simplecov generated +coverage + # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: # # * Create a file at ~/.gitignore diff --git a/Gemfile b/Gemfile index df7f779..85b0c68 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ source "http://rubygems.org" # Add dependencies to develop your gem here. # Include everything needed to run rake, tests, features, etc. group :development do - gem "rspec", "~> 2.8.0" - gem "bundler", "~> 1.0.0" - gem "jeweler", "~> 1.8.0" + gem "rspec" # , "~> 2.8.0" + gem "bundler" # , "~> 1.0.0" + gem "jeweler" # , "~> 1.8.0" + gem 'simplecov', :require => false, :group => :test end diff --git a/Gemfile.lock b/Gemfile.lock index 65179b5..a087964 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,28 +3,34 @@ GEM specs: diff-lcs (1.1.3) git (1.2.5) - jeweler (1.8.3) + jeweler (1.8.4) bundler (~> 1.0) git (>= 1.2.5) rake rdoc - json (1.6.5) + json (1.7.3) + multi_json (1.3.6) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.0) + rspec-expectations (2.11.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.1) + simplecov (0.6.4) + multi_json (~> 1.0) + simplecov-html (~> 0.5.3) + simplecov-html (0.5.3) PLATFORMS ruby DEPENDENCIES - bundler (~> 1.0.0) - jeweler (~> 1.8.0) - rspec (~> 2.8.0) + bundler + jeweler + rspec + simplecov diff --git a/lib/graph.njae/vertex.rb b/lib/graph.njae/vertex.rb index 6e46dcb..aca3fa9 100644 --- a/lib/graph.njae/vertex.rb +++ b/lib/graph.njae/vertex.rb @@ -40,7 +40,7 @@ module GraphNjae end def to_s - '' + '' end end diff --git a/spec/graph/edge_spec.rb b/spec/graph/edge_spec.rb index 8fc71ba..f4be16b 100644 --- a/spec/graph/edge_spec.rb +++ b/spec/graph/edge_spec.rb @@ -25,6 +25,16 @@ module GraphNjae end end # adds attributes + describe "#to_s" do + it "returns the string form of an edge" do + v1 = Vertex.new :name => :v1 + v2 = Vertex.new :name => :v2 + e.type = :test + e << v1 << v2 + e.to_s.should == ', ] >' + end + end + describe "#<<" do it "adds a new vertex to an edge (with a connection)" do e.connections.should be_empty diff --git a/spec/graph/vertex_spec.rb b/spec/graph/vertex_spec.rb index e091289..33b9e03 100644 --- a/spec/graph/vertex_spec.rb +++ b/spec/graph/vertex_spec.rb @@ -25,6 +25,14 @@ module GraphNjae v.score.should == 15 end end # adds attributes + + describe "#to_s" do + it "returns the string form of a vertex" do + v.name = :v1 + v.to_s.should == '' + end + end + describe "#<<" do it "adds a single edge between vertices" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eacf13a..608ead7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,4 @@ -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -$LOAD_PATH.unshift(File.dirname(__FILE__)) -require 'rspec' -require 'graph.njae' - -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} +require 'simplecov' +SimpleCov.start -RSpec.configure do |config| - -end +require 'graph.njae' -- 2.34.1