Sha256: 89d62c8985d06ef9a3b708eb898179d5881506e5a8fd8b211dacceaac95265b9

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

require 'rails'
require 'gmaps4rails'

require 'on_the_map/mappable'


class MyMappableAddress
  include Mongoid::Document
#  include OnTheMap::GeoLocatable
  include OnTheMap::Mappable
end


describe OnTheMap::Mappable do
  subject { address }

  context 'empty address' do
    let(:address) { MyMappableAddress.create street: '', city: ''  }

    it 'should have a blank full address' do
      expect(subject.address.full).to be_blank
    end

    it 'should not be geolocatable' do
      expect(subject.geolocatable?).to be false
    end

    it 'should not be geocoded?' do
      expect(subject.geocoded?).to be false
    end

    it 'should not have a gmaps' do
      expect(subject.gmaps).to_not be true
    end

    it 'should not have a normalized address' do
      expect(subject.normalized_address).to be_blank
    end
  end

  context 'invalid address' do
    let(:address) { MyMappableAddress.create street: 'blip blab', city: 'blop'  }

    it 'should be geolocatable' do
      expect(subject.geolocatable?).to be_true
    end

    it 'should not calculate a position' do
      expect(subject.position.to_a).to be_blank
    end

    it 'should not be geocoded?' do
      expect(subject.geocoded?).to be false
    end 

    it 'should not have a gmaps' do
      expect(subject.gmaps).to_not be_true
    end

    it 'should not have a normalized address' do
      expect(subject.normalized_address).to be_blank
    end       
  end

  context 'valid address' do
    let(:address) { MyMappableAddress.create street: street, city: city  }

    let(:city)    { 'Frederiksberg' }
    let(:street)  { 'Maglekildevej 18, 4th' }

    describe 'creation' do
      its(:city)    { should == city }
      its(:street)  { should == street }

      # leave geocoding to geocoder!
      its(:gmaps_geocode?)  { should be_false }    

      # geocoder sets gmaps when position has been calculated
      its(:gmaps)   { should be_true }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
on_the_map-0.1.0 spec/on_the_map/mappable_spec.rb