Sha256: f3d44757714a3a75ee917c53a94a13427a702dc086682d96363d1997163f6917

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper_acceptance'

describe "my tests" do

  # an example using the beaker DSL
  # use http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL
  it "says hello!" do
    result = shell( 'echo hello' )
    expect(result.stdout).to match(/hello/)
  end

  # an example using Serverspec
  # use http://serverspec.org/resource_types.html
  describe package('puppet') do
    it { is_expected.to be_installed }
  end

  it "can create and confirm a file" do
    shell( 'rm -f demo.txt' )
    create_remote_file(default, 'demo.txt', 'foo\nfoo\nfoo\n')
    shell( 'grep foo demo.txt' )
    shell( 'grep bar demo.txt', :acceptable_exit_codes => [1] )
  end

  it "is able to apply manifests" do
    manifest_1 = "user {'foo':
          ensure => present,}"
    manifest_2 = "user {'foo':
          ensure => absent,}"
    manifest_3 = "user {'root':
          ensure => present,}"
    apply_manifest( manifest_1, :expect_changes => true )
    apply_manifest( manifest_2, :expect_changes => true )
    apply_manifest( manifest_3 )
  end

  describe service('sshd') do
    it { is_expected.to be_running }
  end

  describe user('root') do
    it { is_expected.to exist }
  end

  describe user('foo') do
    it { is_expected.not_to exist }
  end

  context "can use both serverspec and Beaker DSL" do

    it "can create a file" do
      shell( 'rm -f /tmp/demo.txt' )
      manifest = "file {'demofile':
        path    => '/tmp/demo.txt',
        ensure  => present,
        mode    => 0640,
        content => \"this is my file.\",
      }"
      apply_manifest(manifest, :expect_changes => true)
    end

    describe file('/tmp/demo.txt') do
      it { is_expected.to be_file }
      it { is_expected.to contain 'this is my file.' }
    end
  end


end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
beaker-4.42.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.41.2 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.41.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.41.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.40.2 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.40.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.40.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.39.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb