--profile
オプションを使う
普段きちんとRSpecを使っている人にとっては常識なのかもしれません。というか普通にhelpに載っているので常識なのでしょう、、、。
RSpecで遅いテストを見つけるには、--profile
オプションを使うと簡単に見つけることができます。
% bundle exec rspec --profile 3 .................................. Top 3 slowest examples (4.24 seconds, 61.5% of total time): Pooka Pooka::Master Worker#run worker received usr1 signal(signal_handler_thread Error) 1.41 seconds ./spec/pooka_spec.rb:86 Pooka Pooka::Master worker received hup signal(fail config reload) 1.41 seconds ./spec/pooka_spec.rb:109 Pooka Pooka::Master Worker#run worker received hup signal 1.41 seconds ./spec/pooka_spec.rb:53 Top 3 slowest example groups: Pooka 0.76258 seconds average (6.86 seconds / 9 examples) ./spec/pooka_spec.rb:3 Pooka::Configuration 0.00121 seconds average (0.01575 seconds / 13 examples) ./spec/pooka/configuration_spec.rb:5 Pooka::PID 0.00063 seconds average (0.00443 seconds / 7 examples) ./spec/pooka/pid_spec.rb:4 Finished in 6.89 seconds (files took 0.24356 seconds to load) 34 examples, 0 failures
--profile
の後に数値を指定することで出力する件数を調整することもできます。