Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

config specs

  • Loading branch information...
commit 5ba64869ef0d4bb1504d82fe975dd0f7bce9906c 1 parent fe5c8d8
@kristianmandrup authored
View
1  lib/gmaps4rails/base.rb
@@ -8,6 +8,7 @@ module Gmaps4rails
require 'gmaps4rails/extensions/enumerable'
require 'gmaps4rails/extensions/hash'
+ autoload :Config, 'gmaps4rails/config'
autoload :ModelHandler, 'gmaps4rails/model_handler'
autoload :ActsAsGmappable, 'gmaps4rails/acts_as_gmappable'
View
2  lib/gmaps4rails/helper/gmaps4rails_helper.rb
@@ -13,7 +13,7 @@ def gmaps4rails(builder)
# full helper to pass all variables and their options
# @params [Hash] options is a Hash containing data and options. Example: { markers:{ data: @json, options: { do_clustering: true } } }
def gmaps(options = {})
- options = Gmaps4rails.config.load.merge(options)
+ options = Gmaps4rails.config.options.merge(options)
gmaps_libs(options) if options[:with_libs]
View
6 spec/dummy/config/gmaps4rails.yml
@@ -0,0 +1,6 @@
+map_options:
+ provider: mapquest
+ provider_key: 12345
+ auto_adjust: true
+ center_on_user: true
+ zoom: 5
View
55 spec/lib/config_spec.rb
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+
+class Configuration
+ include Gmaps4railsHelper
+end
+
+describe Gmaps4rails::Config::YamlLoader do
+ subject { Gmaps4rails::Config::YamlLoader.new }
+
+ it 'should load a Hash from config file' do
+ subject.load.should be_a Hash
+ end
+
+ it 'should have a config_file' do
+ subject.config_file.should == 'gmaps4rails.yml'
+ end
+
+ it 'should have a config_path' do
+ subject.config_path.to_s.should include('spec/dummy/config/gmaps4rails.yml')
+ end
+
+ describe '#config_file = ' do
+ let(:config_file) { 'gmaps.yml' }
+
+ before :each do
+ subject.config_file = config_file
+ end
+
+ it 'should set it' do
+ subject.config_file.should == config_file
+ end
+
+ it 'should load an empty Hash if no matching config file' do
+ subject.load.should == {}
+ end
+ end
+end
+
+describe Gmaps4rails::Config do
+ subject { Gmaps4rails.config }
+
+ it 'should have a yaml loader' do
+ subject.send(:yaml_loader).should be_a Gmaps4rails::Config::YamlLoader
+ end
+
+ it 'should load options from yaml file' do
+ subject.options.should be_a Hash
+ subject.options.should_not be_empty
+ end
+
+ it 'should load provider map_options from yaml file' do
+ subject.options[:map_options][:provider].should == 'mapquest'
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.