2
# Author:: Doug MacEachern <dougm@vmware.com>
3
# Copyright:: Copyright (c) 2009 VMware, Inc.
4
# License:: Apache License, Version 2.0
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
20
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
22
describe Ohai::System, "plugin lua" do
25
@ohai = Ohai::System.new
26
@ohai[:languages] = Mash.new
27
@ohai.stub!(:require_plugin).and_return(true)
30
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
31
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr])
34
it "should get the lua version from running lua -v" do
35
@ohai.should_receive(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([0, "", "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"])
36
@ohai._require_plugin("lua")
39
it "should set languages[:lua][:version]" do
40
@ohai._require_plugin("lua")
41
@ohai.languages[:lua][:version].should eql("5.1.2")
44
it "should not set the languages[:lua] tree up if lua command fails" do
47
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
48
@ohai.stub!(:run_command).with({:no_status_check=>true, :command=>"lua -v"}).and_return([@status, @stdout, @stderr])
49
@ohai._require_plugin("lua")
50
@ohai.languages.should_not have_key(:lua)