Module: Classifile::AssertChecker

Included in:
State
Defined in:
lib/classifile/checker/assert_checker.rb

Overview

Wrapper class for Minitest::Assertions. Wrap and convert to Failed error when minitest’s Assert method is called.

Defined Under Namespace

Classes: Asserter

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Provides assert methods of minitest.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/classifile/checker/assert_checker.rb', line 25

def method_missing(name, *args)
  @assert = Asserter.new if @assert.nil?
  unless @assert.respond_to?(name) && name.to_s.include?("assert")
    raise NoMethodError.new("Method '#{name}' not found", name)
  end

  begin
    @assert.send name, *args
  rescue MiniTest::Assertion
    raise Failed unless @gotcha
  end
end

Instance Method Details

#respond_to_missing?(sym) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
# File 'lib/classifile/checker/assert_checker.rb', line 38

def respond_to_missing?(sym, *)
  @assert = Asserter.new if @assert.nil?
  if sym.to_s.include?("assert")
    @assert.respond_to?(sym) ? true : super
  else
    super
  end
end