~ubuntu-branches/ubuntu/trusty/ohai/trusty

« back to all changes in this revision

Viewing changes to spec/ohai/plugins/lua_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Timberman
  • Date: 2010-05-12 11:03:32 UTC
  • mfrom: (1.1.5 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100512110332-vpj092y6zwfkk9un
Tags: 0.5.4-4
* Fix use ohai binary from source instead of the one mangled by setup.rb.
* Build-depend graphviz so rdoc gets created properly for ohai-doc.
* Add source/format, version 1.0. Launchpad FTBS on version 3.0 for older
  ubuntu releases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Author:: Doug MacEachern <dougm@vmware.com>
 
3
# Copyright:: Copyright (c) 2009 VMware, Inc.
 
4
# License:: Apache License, Version 2.0
 
5
#
 
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
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
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.
 
17
#
 
18
 
 
19
 
 
20
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
 
21
 
 
22
describe Ohai::System, "plugin lua" do
 
23
 
 
24
  before(:each) do
 
25
    @ohai = Ohai::System.new
 
26
    @ohai[:languages] = Mash.new
 
27
    @ohai.stub!(:require_plugin).and_return(true)
 
28
    @status = 0
 
29
    @stdout = ""
 
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])
 
32
  end
 
33
 
 
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")
 
37
  end
 
38
 
 
39
  it "should set languages[:lua][:version]" do
 
40
    @ohai._require_plugin("lua")
 
41
    @ohai.languages[:lua][:version].should eql("5.1.2")
 
42
  end
 
43
 
 
44
  it "should not set the languages[:lua] tree up if lua command fails" do
 
45
    @status = 1
 
46
    @stdout = ""
 
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)
 
51
  end
 
52
 
 
53
end