Updated

spec/support / time_comparison_helpers.rb

A
27 lines of codes
2 methods
1.5 complexity/method
2 churn
2.9 complexity
0 duplications
RSpec::Matchers.define :be_usec_precise_with do |expected| match do |actual| expect(actual).to be_within(usec_precision).of expected end failure_message do |actual| "\nexpected #{formatted(actual)} to #{description}\n\n\n" end failure_message_when_negated do |actual| "\nexpected #{formatted(actual)} not to #{description}\n\n\n" end description do "be within 1 microsecond of #{formatted(expected)}" end private def usec_precision @_usec ||= 0.000001.seconds end def formatted(object)
  1. formatted doesn't depend on instance state (maybe move it to another class?)
RSpec::Support::ObjectFormatter.format(object) end end