From b435f04528c1107708f52f6110c7bce63fe6f37e Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Fri, 23 Nov 2007 21:06:46 -0700 Subject: fix socket argument to AR and add rails spec --- spec/unit/rails.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 spec/unit/rails.rb (limited to 'spec/unit/rails.rb') 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 -- cgit