Class: Minitest::Markdown::TestClass
- Inherits:
-
Object
- Object
- Minitest::Markdown::TestClass
- Defined in:
- lib/minitest/markdown/test_class.rb
Overview
knows how to build a markdown test class, test methods and ‘state’ methods
Constant Summary collapse
- FENCED_BLOCK_REGEXP =
/^```ruby\n(.*?)\n```/m- BAD_KLASS =
'TestClass must be instantiated with Minitest::Test or subclass thereof'- BAD_PATH =
'Path does not exist, is not readable or is not a Markdown file:'- MD =
'.md'- HOOK_METHODS_BEFORE =
%i[before_all].freeze
- HOOK_METHODS_AFTER =
%i[after_all around around_all].freeze
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #define_methods(stubs: {}) ⇒ Object
-
#initialize(klass, path: nil) ⇒ TestClass
constructor
A new instance of TestClass.
Constructor Details
#initialize(klass, path: nil) ⇒ TestClass
Returns a new instance of TestClass.
23 24 25 26 27 |
# File 'lib/minitest/markdown/test_class.rb', line 23 def initialize(klass, path: nil) @klass = validate_class klass @path = validate_path path @state_methods_defined = [] end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
21 22 23 |
# File 'lib/minitest/markdown/test_class.rb', line 21 def klass @klass end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/minitest/markdown/test_class.rb', line 21 def path @path end |
Instance Method Details
#define_methods(stubs: {}) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/minitest/markdown/test_class.rb', line 29 def define_methods(stubs: {}) i = 0 parse_ruby_blocks.each do |block| next define_non_test_method(block) unless block.type == :test define_test_method(block, i, stub_chain: stubs[i]) i += 1 end end |