class MiniTest::Check::SuiteWrapper

Public Class Methods

new(suite, context) click to toggle source
Calls superclass method
# File lib/minitest-check.rb, line 65
def initialize(suite, context)
  @context = context.kind_of?(Hash) ? OpenStruct.new(context) : context
  super(suite)

  @test_wrapper = Class.new(suite) do
    include Observable
    attr_reader :context
    def initialize(name, _context)
      # Getting a little gnarly here...
      method = self.class.superclass.instance_method(name)
      params = method.parameters.map {|p| p[1]}
      @context = Hash[params.map {|p| [p, _context.send(p)] }]

      super(name)
    end
    
    def run(runner)
      add_observer(runner.collector)
      super(runner).tap do
        runner.report[-1] += " Context: #{@context.inspect}" unless @passed
      end
    end

    private
    def collect(stat_name, stat_value)
      changed
      notify_observers("#{self.class.superclass.name}##{self.__name__}:#{stat_name}", stat_value)#, @context) Waiting until I know how we want to display contexts
      stat_value
    end
  end
  check_methods.each do |name|
    # TODO: fewer horrible metaprogramming hacks
    @test_wrapper.send(:define_method, name) do
      super(*@context.values)
    end
  end
end

Public Instance Methods

check_suite_header(suite) click to toggle source
# File lib/minitest-check.rb, line 107
def check_suite_header(suite)
  puts "Checking with context: #{@context.inspect}"
end
collect(stat_name, stat_value) click to toggle source
# File lib/minitest-check.rb, line 89
def collect(stat_name, stat_value)
  changed
  notify_observers("#{self.class.superclass.name}##{self.__name__}:#{stat_name}", stat_value)#, @context) Waiting until I know how we want to display contexts
  stat_value
end
new(name) click to toggle source
# File lib/minitest-check.rb, line 103
def new(name)
  @test_wrapper.new(name, @context)
end
run(runner) click to toggle source
Calls superclass method
# File lib/minitest-check.rb, line 81
def run(runner)
  add_observer(runner.collector)
  super(runner).tap do
    runner.report[-1] += " Context: #{@context.inspect}" unless @passed
  end
end