Skip to content

Instantly share code, notes, and snippets.

@lgrains
Created May 10, 2014 15:00
Show Gist options
  • Save lgrains/b0aca082cc1111204d8a to your computer and use it in GitHub Desktop.
Save lgrains/b0aca082cc1111204d8a to your computer and use it in GitHub Desktop.
class Graph
attr_accessor :points, :edges
def initialize(array_of_points)
points = Marshal.load(Marshal.dump(array_of_points))
puts "in initialize where graph.points is #{points}"
edges=[]
construct_edges
end
def construct_edges
puts "in construct_edges where points is #{points}"
(0..points.length).each do |f_index|
(ndx..points.length).each do |l_index|
edges << Edge.new(points[f_index],points[l_index])
end
end
end
end
#point_spec.rb
require 'spec_helper'
require 'models/point'
require 'models/edge'
require 'models/graph'
describe Graph, '#points' do
before(:each) do
@p_array = [Point.new(3,5), Point.new(-4,-7), Point.new(14,0), Point.new(2,-5), Point.new(3,0), Point.new(5,-6)]
@graph = Graph.new(@p_array)
puts "in before :each where @graph.points is #{@graph.points}"
end
it "returns a list of points in the Graph" do
puts "in test where @graph.points is #{@graph.points} and @p_array is #{@p_array}"
expect { @graph.points.to == @p_array }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment