Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) + '/../spec_helper'
- module GeoPointSpecHelper
- def auto_migrate!
- GeoPoint.auto_migrate!
- end
- def valid_geo_point
- GeoPoint.new(
- :lat => BigDecimal.new("48.3083343506"),
- :long => BigDecimal.new("14.2847223282")
- )
- end
- def invalid_geo_point
- GeoPoint.new
- end
- end
- shared_examples_for "every GeoPoint" do
- it "should require a lat field" do
- @p.lat = nil
- @p.should_not be_valid
- @p.errors[:lat].should_not be_empty
- end
- it "should require a long field" do
- @p.long = nil
- @p.should_not be_valid
- @p.errors[:long].should_not be_empty
- end
- end
- describe "Every valid GeoPoint" do
- include GeoPointSpecHelper
- before(:each) do
- auto_migrate!
- @p = valid_geo_point
- end
- it_should_behave_like "every GeoPoint"
- it "should be valid if all required fields are set" do
- #@p.should be_valid
- @p.valid?
- puts @p.errors.inspect
- end
- end
- OUTPUT: #<DataMapper::Validate::ValidationErrors:0x370ac94 @errors={:lat=>["Lat must be a number"], :long=>["Long must be a number"]}>
Add Comment
Please, Sign In to add comment