require 'spec_helper'

describe 'default recipe on Ubuntu 14.04' do
  let(:chef_run) do
    ChefSpec::ServerRunner.new do |node|
      node.automatic[:lsb][:codename] = 'trusty'
    end.converge('chef-grafana::default')
  end

  it 'converges successfully' do
    expect { :chef_run }.to_not raise_error
  end
end

require 'spec_helper'

describe 'default recipe on Ubuntu 14.04' do
  let(:chef_run) do
    ChefSpec::ServerRunner.new do |node|
      node.automatic[:lsb][:codename] = 'trusty'
    end.converge('chef-grafana::default')
  end

  let(:chef_run_versioned) do
    ChefSpec::ServerRunner.new do |node|
      node.automatic['chef-grafana']['install']['version'] = '4.5.0'
    end.converge('chef-grafana::default')
  end

  context 'latest version' do
    it 'converges successfully' do
      expect { :chef_run }.to_not raise_error
    end

    it 'upgrades successfully' do
      expect(chef_run).to upgrade_package('grafana')
    end
  end

  context 'specific version' do
    it 'converges successfully' do
      expect { :chef_run_versioned }.to_not raise_error
    end

    it 'installs successfully' do
      expect(chef_run_versioned).to install_package('grafana').with(version: '4.5.0')
    end
  end
end

Add unit test to install a specific version.
Add unit test to install a specific version.

Signed-off-by: Stefan Sundin <0e17f6afaad5343e7f7d39057fdf65e398c03ec8@outreach.io>
