File: implicit_subject.rb

package info (click to toggle)
ruby-maxitest 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 468 kB
  • sloc: ruby: 1,587; makefile: 7
file content (14 lines) | stat: -rw-r--r-- 465 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# this is a bit hacky / overwrites describe, so not included by default ...
module Maxitest
  module ImplicitSubject
    def describe(*args, &block)
      klass = super
      if args.first.is_a?(Class) && !klass.instance_methods(false).include?(:subject)
        klass.let(:subject) { args.first.new }
      end
      klass
    end
  end
end

Object.send(:include, Maxitest::ImplicitSubject) # Minitest hacks Kernel -> we need to use alias method or go into Object