<commit_before>require "rspec"

module Vagrant
  module Spec
    module Acceptance
      # The runner configures RSpec to run the given components.
      class Runner
        def initialize(paths: nil)
          @paths = paths || []
          @world = RSpec::Core::World.new
        end

        def run(components)
          args = [
            "--color",
            "--format", "Vagrant::Spec::Acceptance::Formatter",
          ]

          with_world do
            # Define the provider example group
            Acceptance.config.providers.each do |name, opts|
              g = RSpec::Core::ExampleGroup.describe(
                "provider: #{name}", component: "provider/#{name}")

              # Include any extra contexts defined
              (opts[:contexts] || []).each do |context|
                g.include_context(context)
              end

              g.it_should_behave_like("provider/basic", name, opts)
              g.register
            end

            # Run!
            RSpec::Core::Runner.run(args)
          end
        end

        protected

        def with_world
          # Reset the world so we don't have any components
          @world.example_groups.clear

          # Load the components
          Components.load_default!
          @paths.each do |path|
            Components.load_from!(path)
          end

          # Set the world
          old_world = RSpec.world
          RSpec.world = @world
          yield
        ensure
          RSpec.world = old_world
        end
      end
    end
  end
end<commit_msg>actually set components in proper place<commit_after>require "rspec"

module Vagrant
  module Spec
    module Acceptance
      # The runner configures RSpec to run the given components.
      class Runner
        def initialize(paths: nil)
          @paths = paths || []
          @world = RSpec::Core::World.new
        end

        def run(components)
          args = [
            "--color",
            "--format", "Vagrant::Spec::Acceptance::Formatter",
          ]

          with_world do
            # Run!
            RSpec::Core::Runner.run(args)
          end
        end

        protected

        def with_world
          # Reset the world so we don't have any components
          @world.example_groups.clear

          # Set the world
          old_world = RSpec.world
          RSpec.world = @world

          # Load the components
          Components.load_default!
          @paths.each do |path|
            Components.load_from!(path)
          end

          # Define the provider example group
          Acceptance.config.providers.each do |name, opts|
            g = RSpec::Core::ExampleGroup.describe(
              "provider: #{name}", component: "provider/#{name}")

            # Include any extra contexts defined
            (opts[:contexts] || []).each do |context|
              g.include_context(context)
            end

            g.it_should_behave_like("provider/basic", name, opts)
            g.register
          end

          yield
        ensure
          RSpec.world = old_world
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08576, 'fraction_numerical': 0.0, 'mean_word_length': 1.482922954725973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5815302', 'n_tokens_mistral': 826, 'n_tokens_neox': 793, 'n_words': 220}