Method: Exemplor::Examples#run
- Defined in:
- lib/examples.rb
#run(patterns) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/examples.rb', line 40 def run(patterns) fails = 0 # unoffically supports multiple patterns patterns = Regexp.new(patterns.join('|')) examples_to_run = @examples.select { |name,_| name =~ patterns } return 0 if examples_to_run.empty? examples_to_run.each do |name, code| result = ResultPrinter.new(name, *ExampleEnv.run(&code)) fails +=1 if result.failure? puts($stdout.tty? ? result.fancy : result.yaml) end (fails.to_f/examples_to_run.size)*100 end |