title: RSpec - expected equal?( Time Object ) to return true, got false
body: <p>I'm trying (and failing!) the following code to compare two Time objects in RSpec:</p>
  
  <pre><code>describe '#current_shift_datetime' do
    subject { WipStack.current_shift_datetime }
    it "To be a Time object" do
      expect(subject).to be_kind_of(Time)
    end
    it "To return current shift datetime" do
      # Trying to figure out why they are not equal
      puts subject.in_time_zone.round
      puts 0.day.ago.midnight.in_time_zone.round
  
      # Problematic code here --&gt;
      expect(subject.in_time_zone.round).to be_equal(0.day.ago.midnight.in_time_zone.round)
      # End of problematic code
    end
  end
  </code></pre>
  
  <p>I have read a couple of things in the internet about rspec time comparisong, one of them explaining the problem with the milliseconds (therefore the round) and another page talking about <code>stub</code> but then i ended with <code>An error occurred in an after hook SystemStackError: stack level too deep</code>.</p>
  
  <p>The ouput of the test is:</p>
  
  <pre><code> 1) WipStack#current_shift_datetime To return current shift datetime
      Failure/Error: expect(subject.in_time_zone.round).to be_equal(0.day.ago.midnight.in_time_zone.round)
      expected equal?(Mon, 17 Feb 2014 00:00:00 CST -06:00) to return true, got false
  </code></pre>
  
  <p>The puts output:</p>
  
  <pre><code>#current_shift_datetime
    To be a Time object
    2014-02-17 00:00:00 -0600
    2014-02-17 00:00:00 -0600
    To return current shift datetime (FAILED - 1)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Here is the <code>current_shift_datetime</code> method:</p>
  
  <pre><code>def WipStack.current_shift_datetime(scope = nil)
    shifts = WipStack.get_shifts(scope)
    current_shift = (Time.zone.now - 1.day).strftime("%m/%d/%Y")+" "+shifts.last
    current_time = Time.zone.now.strftime("%H:%M")
    shifts.each do |shift|
      if current_time &gt; shift
        current_shift =  Time.zone.now.strftime("%m/%d/%Y")+" "+shift
      end
    end
    Time.zone.parse(current_shift)
  end
  </code></pre>