Sha256: 3c6ff539b4511678eea607725a31c2abbd3bc90634952152667a48bd93a34566

Contents?: true

Size: 1.74 KB

Versions: 150

Compression:

Stored size: 1.74 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 "should say 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 { should 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 "should be 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 { should be_running }
  end

  describe user('root') do
    it { should exist }
  end

  describe user('foo') do
    it { should_not 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 { should be_file }
    end

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


end

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
beaker-4.38.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.38.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.37.2 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.37.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.37.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.36.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.36.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.35.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.34.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.33.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.32.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.31.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.30.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.29.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.29.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.28.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.28.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.27.1 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.27.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb
beaker-4.26.0 acceptance/fixtures/module/spec/acceptance/demo_spec.rb