summaryrefslogtreecommitdiffstats
path: root/spec/unit/rails.rb
blob: 76fb311c51e24020e0996d42f2b633b3cf1f7ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../spec_helper'
require 'puppet/rails'

describe Puppet::Rails, " when using sqlite3" do
    setup do
        expectation_setup
    end
    
    it "should ignore the database socket argument" do
        Puppet::Rails.database_arguments[:socket].should be_nil
    end
    
    private
        def expectation_setup(extra = {})
            arguments_and_results = {
                :dbadapter      => "sqlite3",
                :rails_loglevel => "testlevel",
                :dblocation     => "testlocation"
            }.merge(extra)
            
            arguments_and_results.each do |argument, result|
                Puppet.settings.expects(:value).with(argument).returns(result)
            end
        end
end

describe Puppet::Rails, " when not using sqlite3" do
    it "should set the dbsocket argument if not empty" do
        expectation_setup
        Puppet::Rails.database_arguments[:socket].should == "testsocket"
    end
    
    it "should not set the dbsocket argument if empty" do
        expectation_setup(:dbsocket => "")
        Puppet::Rails.database_arguments[:socket].should be_nil
    end
    
    private
        def expectation_setup(extra = {})
            arguments_and_results = {
                :dbadapter      => "mysql",
                :rails_loglevel => "testlevel",
                :dbserver       => "testserver",
                :dbuser         => "testuser",
                :dbpassword     => "testpassword",
                :dbname         => "testdb",
                :dbsocket       => "testsocket"
            }.merge(extra)
            
            arguments_and_results.each do |argument, result|
                Puppet.settings.expects(:value).with(argument).returns(result)
            end
        end
end