Sha256: 2f5b9eecb8438c06cd09f4be17c6220bc46747bcaa45c71627df5e54364eddf4

Contents?: true

Size: 555 Bytes

Versions: 66

Compression:

Stored size: 555 Bytes

Contents

class Module
  def focus *wanteds
    wanteds.map! { |m| m.to_s }
    unwanteds = public_instance_methods(false).grep(/test_/).map(&:to_s)
    unwanteds -= wanteds
    unwanteds.each do |unwanted|
      remove_method unwanted
    end
  end

  def focus_re regexp
    focus(*public_instance_methods.grep(regexp))
  end

  def blur
    parent = self.superclass

    ObjectSpace.each_object Class do |klass|
      next unless parent > klass
      next if klass == self

      klass.send :focus
      klass.send :undef_method, :default_test
    end
  end
end

Version data entries

66 entries across 66 versions & 5 rubygems

Version Path
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.2/lib/focus.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.2/lib/focus.rb
ZenTest-4.12.2 lib/focus.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-1.120.3 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb
cloudsmith-api-1.61.3 vendor/bundle/ruby/2.6.0/gems/ZenTest-4.12.1/lib/focus.rb