[rspec-users] Testing equality

Juanma Cervera lists at ruby-forum.com
Fri Jul 9 03:37:05 EDT 2010


The updated_at has class ActiveSupport::TimeWithZone

v.updated_at.should == f.updated_at fails
v.updated_at.to_datetime.should == f.to_datetime.updated_at fails

v.updated_at.to_s.should == f.updated_at.to_s works
v.updated_at.to_i.should == f.updated_at.to_i works

And adding this method to the model doesn't work either.

  def ==(other)
    (self.attributes.merge(:created_at => 
Datetime.new(self.created_at.to_s),
                           :updated_at => 
Datetime.new(self.updated_at.to_s)) ==
    (other.attributes.merge(:created_at => 
Datetime.new(self.other_at.to_s),
                            :updated_at => 
Datetime.new(self.other_at.to_s))
  end

Thanks
Juanma
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list