Sha256: d69adb421de68bf390225e5e1b8251b083a38542bda026073865d706846c7db9

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

# https://relishapp.com/rspec/rspec-core/v/3-6/docs/example-groups/shared-examples
RSpec.shared_examples 'plugin_tests' do |_parameter|
  let(:plugin) do
    instance = PuppetDebugger::InputResponders::Commands.plugin_from_command(subject.to_s).instance
    instance.debugger = debugger
    instance
  end

  let(:output) do
    StringIO.new
  end

  let(:debugger) do
    PuppetDebugger::Cli.new({ out_buffer: output }.merge(options))
  end

  let(:options) do
    {}
  end

  it 'commands contant is an array' do
    expect(plugin.class::COMMAND_WORDS).to be_a(Array)
  end

  it 'commands must contain at least one word' do
    expect(plugin.class::COMMAND_WORDS.count).to be > 0
  end

  it 'summary must be a string' do
    expect(plugin.class::SUMMARY).to be_a(String)
  end

  it 'implements run' do
    expect { plugin.run([]) }.not_to raise_error
  end

  it 'be looked up via any command words' do
    plugin.class::COMMAND_WORDS.each do |word|
      actual = PuppetDebugger::InputResponders::Commands.plugin_from_command(word.to_s).instance.class
      expect(actual).to eq(plugin.class)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-debugger-1.3.0 lib/puppet-debugger/plugin_test_helper.rb
puppet-debugger-1.2.0 lib/puppet-debugger/plugin_test_helper.rb
puppet-debugger-1.1.0 lib/puppet-debugger/plugin_test_helper.rb
puppet-debugger-1.0.0 lib/puppet-debugger/plugin_test_helper.rb