diff options
-rw-r--r-- | lib/puppet/rails.rb | 2 | ||||
-rw-r--r-- | spec/unit/rails.rb | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index 55d03b878..e87e22a68 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -45,7 +45,7 @@ module Puppet::Rails args[:username] = Puppet[:dbuser] args[:password] = Puppet[:dbpassword] args[:database] = Puppet[:dbname] - args[:args] = Puppet[:dbsocket] unless Puppet[:dbsocket] == "" + args[:socket] = Puppet[:dbsocket] unless Puppet[:dbsocket] == "" else raise ArgumentError, "Invalid db adapter %s" % Puppet[:dbadapter] end diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb new file mode 100644 index 000000000..9ffb4b537 --- /dev/null +++ b/spec/unit/rails.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../spec_helper' +require 'puppet/rails' + +describe Puppet::Rails, " when using sqlite3" do + setup do + @old_adapter = Puppet[:dbadapter] + @old_dbsocket = Puppet[:dbsocket] + + Puppet[:dbadapter] = "sqlite3" + end + + teardown do + Puppet[:dbadapter] = @old_adapter + Puppet[:dbsocket] = @old_dbsocket + end + + it "should ignore the database socket argument" do + Puppet[:dbsocket] = "blah" + Puppet::Rails.database_arguments[:socket].should be_nil + end +end + +describe Puppet::Rails, " when not using sqlite3" do + setup do + @old_adapter = Puppet[:dbadapter] + @old_dbsocket = Puppet[:dbsocket] + + Puppet[:dbadapter] = "mysql" + end + + teardown do + Puppet[:dbadapter] = @old_adapter + Puppet[:dbsocket] = @old_dbsocket + end + + it "should set the dbsocket argument if not empty " do + Puppet[:dbsocket] = "blah" + Puppet::Rails.database_arguments[:socket].should == "blah" + end + + it "should not set the dbsocket argument if empty" do + Puppet[:dbsocket] = "" + Puppet::Rails.database_arguments[:socket].should be_nil + end +end
\ No newline at end of file |