rspecwindows-installerserverspec

How to check whether the msi with particular version installed using serverspec?


We are trying to validate the application installation using ServerSpec in windows. I have written the following lines in ruby file (with Test.rb)

require 'spec_helper'

set :backend, :cmd

set :os, :family => 'windows'

describe package('ApplicationCorePackage') do
  it { should be_installed }
end

I ran the script like this.

rspec 'C:\Ruby Scripts\Test.rb' --format html --out 'C:\Ruby Scripts\Test.html'

It is checking that correctly. But i want to check for particular version of the msi(windows installer package). How to do that in serverspec?


Solution

  • Check documentation at: http://serverspec.org/resource_types.html#package

    The matcher be_installed accepts the chain with_version. Therefore, with RSpec 3 syntax we have:

    describe package('ApplicationCorePackage') do
      it { expect(subject).to be_installed.with_version('version') }
    end
    

    If your question is whether you need a by chain for the MSI provider, then the answer is that you do not.