Sha256: 4ba9201a04854f8a5ff8a1b081b672e739b9b81c55f52980feee7ec53dba2495

Contents?: true

Size: 1.4 KB

Versions: 70

Compression:

Stored size: 1.4 KB

Contents

require "rspec"

require "vagrant-spec"

module Vagrant
  module Spec
    class Components
      def initialize(paths)
        @paths = paths
        reload!
      end

      # Loads the components from the given paths
      def reload!
        # Delete the existing example groups
        RSpec.world.example_groups.clear

        @paths.each do |path|
          Dir.glob(File.join(path, "**/*_{output,spec}.rb")).each do |single|
            load single
          end
        end
      end

      # Returns the defined components that are runnable.
      #
      # @return [Array<String>]
      def components
        [].tap do |result|
          RSpec.world.example_groups.each do |group|
            next if !group.metadata.has_key?(:component)
            result << group.metadata[:component]
          end
        end
      end

      # Returns the defined provider features.
      def provider_features
        [].tap do |result|
          groups = RSpec.world.shared_example_group_registry.send(:shared_example_groups)
          groups[:main].each do |name, _|
            match = /^provider\/(.+?)$/.match(name)
            result << match[1] if match
          end
        end
      end

      protected

      # This loads the default components that are packaged with
      # the vagrant-spec gem.
      def self.load_default!
        load_from!(Vagrant::Spec.source_root.join("acceptance"))
      end
    end
  end
end

Version data entries

70 entries across 21 versions & 1 rubygems

Version Path
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/bundler/gems/vagrant-spec-03d88fe24677/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.6.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-148cb63d6d06/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-93c587f3c98a/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-148cb63d6d06/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.6.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/bundler/gems/vagrant-spec-03d88fe24677/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-93c587f3c98a/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-93c587f3c98a/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/bundler/gems/vagrant-spec-b6b56c8b8135/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-148cb63d6d06/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.6.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-spec-abfc34474d12/lib/vagrant-spec/components.rb