Skip to content

Commit

Permalink
more specs
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Feb 10, 2011
1 parent 43626d2 commit f63e64f
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 8 deletions.
39 changes: 36 additions & 3 deletions spec/geo_magic/radius/rectangular_spec.rb
Expand Up @@ -19,30 +19,63 @@

it "should create a new rectangular radius that is square" do
rect = GeoMagic::RectangularRadius.new center, distance
rect.vector_distance.lat_distance.should == rect.vector_distance.long_distance
puts rect.inspect
end
end

describe '#double' do
describe '#double!' do
let (:rect) do
GeoMagic::RectangularRadius.new center, vector_distance
end

it "should double the radius distance" do
old_lat = rect.vector_distance.lat_distance
old_long = rect.vector_distance.long_distance
rect.double!
rect.vector_distance.lat_distance.should == old_lat * 2
rect.vector_distance.long_distance.should == old_long * 2
puts rect.inspect
end
end

describe '#double' do
let (:rect) do
GeoMagic::RectangularRadius.new center, vector_distance
end

it "should double the radius distance" do
other_rect = rect.double
other_rect.vector_distance.should_not == rect.vector_distance
puts rect.inspect
end
end

describe '#halve' do
describe '#halve!' do
let (:rect) do
GeoMagic::RectangularRadius.new center, distance
end

it "should halve the radius distance" do
old_lat = rect.vector_distance.lat_distance
old_long = rect.vector_distance.long_distance
rect.halve!
rect.vector_distance.lat_distance.should == old_lat / 2
rect.vector_distance.long_distance.should == old_long / 2

puts rect.inspect
end
end


describe '#halve' do
let (:rect) do
GeoMagic::RectangularRadius.new center, vector_distance
end

it "should double the radius distance" do
other_rect = rect.halve
other_rect.vector_distance.should_not == rect.vector_distance
puts rect.inspect
end
end
end
71 changes: 66 additions & 5 deletions spec/geo_magic/radius/square_spec.rb
@@ -1,16 +1,77 @@
require 'spec_helper'

describe GeoMagic::SquareRadius do
describe '#new' do
let(:center) do
{:lat => 40, :long => 11}
let(:center) do
{:lat => 40, :long => 11}
end

let(:distance) { 0.5.km }

let(:center_point) do
GeoMagic::Point.new :lat => 40, :long => 11
end


describe '#new' do
it "should create a new square radius from an array" do
square = GeoMagic::SquareRadius.new [30, 10], distance
puts square.inspect
end

let(:distance) { 0.5.km }

it "should create a new square radius" do
square = GeoMagic::SquareRadius.new center, distance
puts square.inspect
end

it "should create a new square radius from a point" do
square = GeoMagic::SquareRadius.new center_point, distance
puts square.inspect
end
end

describe '#double' do
let (:square) do
GeoMagic::SquareRadius.new center, distance
end

it "should double the radius distance and return new square" do
other_square = square.double
other_square.distance.should_not == square.distance
puts square.inspect
end
end

describe '#double!' do
let (:square) do
GeoMagic::SquareRadius.new center, distance
end

it "should double the radius distance" do
square.double!
puts square.inspect
end
end

describe '#halve' do
let (:square) do
GeoMagic::SquareRadius.new center, distance
end

it "should halve the radius distance and return new square" do
other_square = square.halve
other_square.distance.should_not == square.distance
puts square.inspect
end
end

describe '#halve!' do
let (:square) do
GeoMagic::SquareRadius.new center, distance
end

it "should halve the radius distance" do
square.halve!
puts square.inspect
end
end
end

0 comments on commit f63e64f

Please sign in to comment.