Sha256: 85dc066d83c03856c823d183128cc62b6727afe873cc24b651311882e2a6996a

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require './lib/gmaps4rails/markers_builder'

describe Gmaps4rails::MarkersBuilder do

  describe "call" do
    let(:lat) { 40 }
    let(:lng) { 5  }
    let(:id)  { 'id' }
    let(:infowindow) { 'some infowindow content' }
    let(:name)       { 'name' }
    let(:picture)    { {
      :url    => "http://www.blankdots.com/img/github-32x32.png",
      :width  => "32",
      :height => "32"
    }}
    let(:expected_hash) { {
      :lat          => lat,
      :lng          => lng,
      :marker_title => name,
      :some_id      => id,
      :infowindow   => infowindow,
      :picture      => picture
    }}
    let(:object) { OpenStruct.new(
      :latitude  => lat,
      :longitude => lng,
      :name      => name,
      :some_id   => id
    )}

    let(:action) { Gmaps4rails::MarkersBuilder.new(object).call do |user, marker|
        marker.lat        user.latitude
        marker.lng        user.longitude
        marker.infowindow infowindow
        marker.picture    picture
        marker.title      user.name
        marker.json({ :some_id => user.some_id })
      end
    }

    it "creates expected hash" do
      expect(action).to eq [expected_hash]
    end

  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gmaps4rails-2.0.4 spec/lib/markers_builder_spec.rb
gmaps4rails-2.0.3 spec/lib/markers_builder_spec.rb
gmaps4rails-2.0.2 spec/lib/markers_builder_spec.rb
gmaps4rails-2.0.1 spec/lib/markers_builder_spec.rb
gmaps4rails-2.0.0 spec/lib/markers_builder_spec.rb