Sha256: f8607aa5d0136c2982ffd1da5345ca37d533eda1503293298db62bae6c063432

Contents?: true

Size: 1.66 KB

Versions: 20

Compression:

Stored size: 1.66 KB

Contents

require "rspec"

require "vagrant-spec"

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

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

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

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

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

      protected

      def with_world
        old_world = RSpec.world
        RSpec.world = @world
        yield
      ensure
        RSpec.world = old_world
      end

      # 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

20 entries across 11 versions & 2 rubygems

Version Path
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-1d09951eaef3/lib/vagrant-spec/components.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-9bba7e122837/lib/vagrant-spec/components.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-spec-1df5a3af81cb/lib/vagrant-spec/components.rb