selective-ruby-rspec 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a52be67f13b3bf3813e3cc0957691927ed27e5e80648d1956c09ad41484c4f52
         | 
| 4 | 
            +
              data.tar.gz: d32e9422fd5d88e8a0b7ce4431e42efbd59fad050689e163b88f91e6a08fc9e2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4ad06bc5a9b33456299db63400c2c4ced95cbe9697af8bd637289419be5c4d59edd6f7264a8b29f96005694b4163bb01c669c9dc1f33eb69b798321a0174b564
         | 
| 7 | 
            +
              data.tar.gz: fa656253c173a3d7363f7ad3d97d5f4af8297404b8ee4dd820a4736a8c0035a751063452fb9ffbd6d781f61b75532c386398aaf0edf35ea7c452c92274690031
         | 
| @@ -5,7 +5,8 @@ module Selective | |
| 5 5 | 
             
                    MAP = {
         | 
| 6 6 | 
             
                      "BaseTextFormatter" => [:message, :dump_pending, :seed, :close],
         | 
| 7 7 | 
             
                      "ProgressFormatter" => [:start_dump],
         | 
| 8 | 
            -
                      "DocumentationFormatter" => [:message]
         | 
| 8 | 
            +
                      "DocumentationFormatter" => [:message],
         | 
| 9 | 
            +
                      "ProfileFormatter" => [:dump_profile]
         | 
| 9 10 | 
             
                    }
         | 
| 10 11 |  | 
| 11 12 | 
             
                    MAP.each do |module_name, methods|
         | 
| @@ -67,6 +68,26 @@ module Selective | |
| 67 68 | 
             
                      def get_files_to_run(*args)
         | 
| 68 69 | 
             
                        super.reject { |f| loaded_spec_files.member?(f) }
         | 
| 69 70 | 
             
                      end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                      def with_suite_hooks
         | 
| 73 | 
            +
                        return yield if dry_run?
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                        unless @before_suite_hooks_run
         | 
| 76 | 
            +
                          ::RSpec.current_scope = :before_suite_hook
         | 
| 77 | 
            +
                          run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
         | 
| 78 | 
            +
                          @before_suite_hooks_run = true
         | 
| 79 | 
            +
                        end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                        yield
         | 
| 82 | 
            +
                      end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                      def after_suite_hooks
         | 
| 85 | 
            +
                        return if dry_run?
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                        ::RSpec.current_scope = :after_suite_hook
         | 
| 88 | 
            +
                        run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
         | 
| 89 | 
            +
                        ::RSpec.current_scope = :suite
         | 
| 90 | 
            +
                      end
         | 
| 70 91 | 
             
                    end
         | 
| 71 92 |  | 
| 72 93 | 
             
                    module World
         | 
| @@ -85,7 +106,7 @@ module Selective | |
| 85 106 | 
             
                    module Example
         | 
| 86 107 | 
             
                      def initialize(*args)
         | 
| 87 108 | 
             
                        super
         | 
| 88 | 
            -
                        ::RSpec.world.example_map[id] = example_group
         | 
| 109 | 
            +
                        ::RSpec.world.example_map[id] = example_group.parent_groups.last
         | 
| 89 110 | 
             
                      end
         | 
| 90 111 |  | 
| 91 112 | 
             
                      def run(*args)
         | 
| @@ -108,6 +129,27 @@ module Selective | |
| 108 129 | 
             
                      end
         | 
| 109 130 | 
             
                    end
         | 
| 110 131 |  | 
| 132 | 
            +
                    module RSpec
         | 
| 133 | 
            +
                      unless ::RSpec.respond_to?(:current_scope)
         | 
| 134 | 
            +
                        def current_scope=(scope)
         | 
| 135 | 
            +
                          # No-op! Older versions of RSpec don't have this method.
         | 
| 136 | 
            +
                          # so we're adding it here if it's not defined since our
         | 
| 137 | 
            +
                          # monkeypatching references it.
         | 
| 138 | 
            +
                        end
         | 
| 139 | 
            +
                      end
         | 
| 140 | 
            +
                    end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    module Hooks
         | 
| 143 | 
            +
                      hooks = %i(before prepend_before after append_after)
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                      hooks.each do |hook|
         | 
| 146 | 
            +
                        define_method(hook) do |*args, &block|
         | 
| 147 | 
            +
                          args = args.map { |a| a == :all ? :each : a }
         | 
| 148 | 
            +
                          super(*args, &block)
         | 
| 149 | 
            +
                        end
         | 
| 150 | 
            +
                      end
         | 
| 151 | 
            +
                    end
         | 
| 152 | 
            +
             | 
| 111 153 | 
             
                    def self.apply
         | 
| 112 154 | 
             
                      ::RSpec::Support.require_rspec_core("formatters/base_text_formatter")
         | 
| 113 155 |  | 
| @@ -117,12 +159,19 @@ module Selective | |
| 117 159 | 
             
                          .prepend(Selective::Ruby::RSpec::Monkeypatches.const_get(module_name))
         | 
| 118 160 | 
             
                      end
         | 
| 119 161 |  | 
| 120 | 
            -
                      ::RSpec::Core:: | 
| 121 | 
            -
                       | 
| 122 | 
            -
                       | 
| 123 | 
            -
                       | 
| 124 | 
            -
                      ::RSpec::Core:: | 
| 125 | 
            -
             | 
| 162 | 
            +
                      # We'd like to prepend to ::RSpec::Core::Hooks here but there is
         | 
| 163 | 
            +
                      # a bug in < Ruby 3.0 that prevents us from doing so. Instead,
         | 
| 164 | 
            +
                      # we extend the ExampleGroup class which is where the Hooks module
         | 
| 165 | 
            +
                      # is included.
         | 
| 166 | 
            +
                      ::RSpec::Core::ExampleGroup.extend(Hooks)
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                      ::RSpec.singleton_class.prepend(RSpec)
         | 
| 169 | 
            +
                      ::RSpec::Core::Reporter.prepend(Reporter)
         | 
| 170 | 
            +
                      ::RSpec::Core::Configuration.prepend(Configuration)
         | 
| 171 | 
            +
                      ::RSpec::Core::World.prepend(World)
         | 
| 172 | 
            +
                      ::RSpec::Core::Runner.prepend(Runner)
         | 
| 173 | 
            +
                      ::RSpec::Core::Example.prepend(Example)
         | 
| 174 | 
            +
                      ::RSpec::Core::Metadata::HashPopulator.prepend(MetaHashPopulator)
         | 
| 126 175 | 
             
                    end
         | 
| 127 176 | 
             
                  end
         | 
| 128 177 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: selective-ruby-rspec
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Benjamin Wood
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: exe
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2023- | 
| 12 | 
            +
            date: 2023-12-06 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: zeitwerk
         |