Introduce tool Duplicate Blocker and its spec

You are right, specially the reliably controlling of the timing. I have replaced with timecop calls. Now the test takes no time. 

----- Original Message -----
From: "Erik" <notifications@github.com>
To: "ManageIQ/manageiq" <manageiq@noreply.github.com>
Cc: "bzwei" <bilwei@redhat.com>
Sent: Tuesday, August 5, 2014 5:23:38 PM
Subject: Re: [manageiq] Introduce tool Duplicate Blocker and its spec (#25)

> +
> +  it 'should remove outdated history' do
> +    assert_safe_calls :instance, 1, SHORT_TIME, 'arg1', 'arg2'
> +    assert_safe_calls :class, 1, SHORT_TIME, 'arg3'
> +    sleep TIME_WINDOW / 2
> +    assert_safe_calls :instance, 1, SHORT_TIME, 'arg1', 'arg2'
> +    sleep TIME_WINDOW / 2
> +    @dedup_handler.histories.size.should eq 2
> +    @dedup_handler.purge_histories
> +    @dedup_handler.histories.size.should eq 1
> +  end
> +
> +  private
> +
> +  def make_a_call(meth, delay)
> +    sleep delay

I disagree with this. The whole thing is 10 tests, and 0.4 seconds in my opinion is slow for 10 tests, especially since we don't need to be hitting the database at all.

Also controlling the time is always going to be more reliable than sleeping and hoping that it was either long enough or short enough to produce the results that you want. Getting false positives or vice versa every once in a while removes the confidence in the specs.

---
Reply to this email directly or view it on GitHub:
https://github.com/ManageIQ/manageiq/pull/25/files#r15842904