# # Author:: Cary Penniman () # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb') describe Ohai::System, "plugin rightscale" do before(:each) do @ohai = Ohai::System.new @ohai.stub!(:require_plugin).and_return(true) end describe "ec2 with RightScale platform" do before(:each) do @ohai[:ec2] = Mash.new() @ohai[:ec2][:userdata] = "RS_api_url=https:\/\/my.rightscale.com\/api\/inst\/ec2_instances\/c18c07eb8d33456db3d75fe65c56e8bae94d8f59&RS_server=my.rightscale.com&RS_sketchy=sketchy1-12.rightscale.com&RS_token=e668bb0be59d061b8b60f08765902a90" end it "should create rightscale mash" do @ohai._require_plugin("rightscale") @ohai[:rightscale].should_not be_nil end it "should create rightscale server mash" do @ohai._require_plugin("rightscale") @ohai[:rightscale][:server].should_not be_nil end it "should populate sketchy server attribute" do @ohai._require_plugin("rightscale") @ohai[:rightscale][:server]['sketchy'].should == "sketchy1-12.rightscale.com" end it "should populate core server attribute" do @ohai._require_plugin("rightscale") @ohai[:rightscale][:server][:core].should == "my.rightscale.com" end it "should populate token attribute" do @ohai._require_plugin("rightscale") @ohai[:rightscale][:token].should == "e668bb0be59d061b8b60f08765902a90" end end describe "ec2 without rightscale" do before(:each) do @ohai[:ec2] = Mash.new() @ohai[:ec2][:userdata] = "some other form of userdata" end it "should NOT populate the rightscale data" do @ohai._require_plugin("rightscale") @ohai[:rightscale].should be_nil end end end