Module: CapybaraTestHelpers::BenchmarkHelpers::ClassMethods
- Defined in:
- lib/capybara_test_helpers/benchmark_helpers.rb
Instance Method Summary collapse
-
#benchmark(method_names) ⇒ Object
Debug: Wraps a method to output its parameters and ellapsed time.
-
#benchmark_all ⇒ Object
Debug: Wraps all instance methods of the test helper class to log them.
-
#on_test_helper_load ⇒ Object
Hook: Benchmarks all methods in the class once it’s loaded.
Instance Method Details
#benchmark(method_names) ⇒ Object
Debug: Wraps a method to output its parameters and ellapsed time.
Usage:
benchmark :input_for
benchmark def input_for(...)
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/capybara_test_helpers/benchmark_helpers.rb', line 75 def benchmark(method_names) prepend(Module.new { Array.wrap(method_names).each do |method_name| define_method(method_name) { |*args, **kwargs, &block| benchmark_method(method_name, args, kwargs) { super(*args, **kwargs, &block) } } end }) method_names end |
#benchmark_all ⇒ Object
Debug: Wraps all instance methods of the test helper class to log them.
63 64 65 66 67 68 |
# File 'lib/capybara_test_helpers/benchmark_helpers.rb', line 63 def benchmark_all return if defined?(@benchmarked_all) benchmark(instance_methods - superclass.instance_methods - [:lazy_for]) @benchmarked_all = true end |
#on_test_helper_load ⇒ Object
Hook: Benchmarks all methods in the class once it’s loaded.
57 58 59 60 |
# File 'lib/capybara_test_helpers/benchmark_helpers.rb', line 57 def on_test_helper_load super benchmark_all end |