require 'spec_helper'

describe 'yum_test::test_repository_six' do
  let(:test_repository_six_run) do
    ChefSpec::Runner.new(
      :step_into => 'yum_repository'
      ).converge(described_recipe)
  end

  let(:test_repository_six_template) do
    test_repository_six_run.template('/etc/yum.repos.d/test6.repo')
  end

  let(:test_repository_six_content) do
    '# This file was generated by Chef
# Do NOT modify this file by hand.

[test6]
name=an test
baseurl=http://drop.the.baseurl.biz
enabled=1
gpgcheck=1
sslverify=true
'
  end

  context 'creating a yum_repository with minimal parameters' do
    it 'creates yum_repository[test6]' do
      expect(test_repository_six_run).to create_yum_repository('test6')
    end

    it 'steps into yum_repository and upgrades package[ca-certificates]' do
      expect(test_repository_six_run).to upgrade_package('ca-certificates')
    end

    it 'steps into yum_repository and creates template[/etc/yum.repos.d/test6.repo]' do
      expect(test_repository_six_run).to create_template('/etc/yum.repos.d/test6.repo')
    end

    it 'steps into yum_repository and renders file[/etc/yum.repos.d/test6.repo]' do
      expect(test_repository_six_run).to render_file('/etc/yum.repos.d/test6.repo').with_content(test_repository_six_content)
    end

    it 'steps into yum_repository and runs execute[yum-makecache-test6]' do
      expect(test_repository_six_run).to_not run_execute('yum-makecache-test6')
    end

    it 'steps into yum_repository and runs ruby_block[yum-cache-reload-test6]' do
      expect(test_repository_six_run).to_not run_ruby_block('yum-cache-reload-test6')
    end

    it 'sends a :run to execute[yum-makecache-test6]' do
      expect(test_repository_six_template).to notify('execute[yum-makecache-test6]')
    end

    it 'sends a :create to ruby_block[yum-cache-reload-test6]' do
      expect(test_repository_six_template).to notify('ruby_block[yum-cache-reload-test6]')
    end
  end

end
