Sha256: 9c00246cdd0b3acdeaf770987b7bda092fecca668c30e7eda0330cfc484b7cff

Contents?: true

Size: 900 Bytes

Versions: 3

Compression:

Stored size: 900 Bytes

Contents

module CaptainHoog
  module Test
    module RSpec
      module TestCase

        attr_reader :plugin

        def with_plugin(plugin_name, config: nil, silence: false)
          before do
            cfg = config ? self.send(config) : {}
            cfg.merge!(env: { suppress_headline: silence }) if silence
            build_sandbox(plugin_name, cfg)
          end
          context "with plugin #{plugin_name}" do
            yield if block_given?
          end
        end

        private

        def build_sandbox(plugin_name, cfg)
          plugin_code  = self.send(plugin_name)
          sandbox      = CaptainHoog::Test::Sandbox.new(plugin_code, cfg)
          sandbox.run
          @plugin      = sandbox.plugin
        end

      end
    end
  end
end

RSpec.configure do |config|
  config.include CaptainHoog::Test::RSpec::TestCase
  config.extend CaptainHoog::Test::RSpec::TestCase
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
captain_hoog-2.0.0 lib/captain_hoog/test/rspec.rb
captain_hoog-1.1.1 lib/captain_hoog/test/rspec.rb
captain_hoog-1.1.0 lib/captain_hoog/test/rspec.rb