class Cat Crazy = Class.new(Cat) LazyError = Class.new(StandardError) # Makes cat play with a string. # # *Examples*: # cat = Cat.new # crazy = cat.play_with('long string') # crazy.class # #=> Cat::Crazy # # *Parameters*: # - +play_with+ - Object to play with # *Returns*: # - crazy cat # *Raises*: # - +Cat::LazyError+ if play_with is not a string def play(play_with) if play_with.is_a?(String) Crazy.new else raise LazyError, "I'm too lazy to play with #{play_with.inspect}." end end end
class Cat Crazy = Class.new(Cat) LazyError = Class.new(StandardError)
# Public: Makes cat play with a string. # # play_with - The String to play with # # Examples # # cat = Cat.new # crazy = cat.play_with('long string') # crazy.class # #=> Cat::Crazy # # Raises a Cat::LazyError if play_with is not a string. # # Returns a Cat::Crazy. def play(play_with) if play_with.is_a?(String) Crazy.new else raise LazyError, "I'm too lazy to play with #{play_with.inspect}." end end end
class Cat # Public: Makes cat play with a string. # # play_with - The String to play with # # Examples # # cat = Cat.new # crazy = cat.play_with('long string') # crazy.class # #=> Cat::Crazy # # Raises a Cat::LazyError if play_with is not a string. # # Returns a Cat::Crazy. def play(play_with) if play_with.is_a?(String) Crazy.new else raise LazyError, "I'm too lazy to play with #{play_with.inspect}." end end end
class Cat Crazy = Class.new(Cat) LazyError = Class.new(StandardError)
# Makes cat play with a string. # # @example # cat = Cat.new # crazy = cat.play_with('long string') # crazy.class # #=> Cat::Crazy # # @param [String] play_with to play with # @raise [Cat::LazyError] if play_with is not a string # @return [Cat::Crazy] crazy cat def play(play_with) if play_with.is_a?(String) Crazy.new else raise LazyError, "I'm too lazy to play with #{play_with.inspect}." end end end
$ python example.py -v 5 Trying: sum(1, 1) Expecting: 2 ok Trying: sum(1, -1) Expecting: 0 ok 1 items had no tests: __main__.sum 1 items passed all tests: 2 tests in __main__ 2 tests in 2 items. 2 passed and 0 failed. Test passed.
p0deje/yard-doctest - Парсит текст example тэга - Получает из текста expected, actual - Генерирует Minitest::Spec классы - Все остальное делает Minitest