Sha256: ac5fd703c10cb09e7fd5156f0db2634d303ebe2881d403c845e26c6547e6cd88

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

class ClassMixedWithDSLStructure
  include Beaker::DSL::Structure
end

describe ClassMixedWithDSLStructure do
  let(:logger) { Object.new }
  describe '#step' do
    it 'requires a name' do
      expect { subject.step do; end }.to raise_error ArgumentError
    end

    it 'notifies the logger' do
      expect( subject ).to receive( :logger ).and_return( logger )
      expect( logger ).to receive( :notify )
      subject.step 'blah'
    end

    it 'yields if a block is given' do
      expect( subject ).to receive( :logger ).and_return( logger )
      expect( logger ).to receive( :notify )
      expect( subject ).to receive( :foo )
      subject.step 'blah' do
        subject.foo
      end
    end
  end

  describe '#test_name' do
    it 'requires a name' do
      expect { subject.test_name do; end }.to raise_error ArgumentError
    end

    it 'notifies the logger' do
      expect( subject ).to receive( :logger ).and_return( logger )
      expect( logger ).to receive( :notify )
      subject.test_name 'blah'
    end

    it 'yields if a block is given' do
      expect( subject ).to receive( :logger ).and_return( logger )
      expect( logger ).to receive( :notify )
      expect( subject ).to receive( :foo )
      subject.test_name 'blah' do
        subject.foo
      end
    end
  end

  describe '#teardown' do
    it 'append a block to the @teardown var' do
      teardown_array = double
      subject.instance_variable_set :@teardown_procs, teardown_array
      block = lambda { 'blah' }
      expect( teardown_array ).to receive( :<< ).with( block )
      subject.teardown &block
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
beaker-2.3.0 spec/beaker/dsl/structure_spec.rb
beaker-2.2.0 spec/beaker/dsl/structure_spec.rb
beaker-2.1.0 spec/beaker/dsl/structure_spec.rb
beaker-2.0.0 spec/beaker/dsl/structure_spec.rb