Saturday, 15 January 2011

ruby on rails - Rspec test Comparable -


I have a model that uses comparative and I required & lt ; = & Gt; For this method how should I go about this w / rspec test (I know that this is not TDD because I have already applied the method)?

  class grades & lt; ActiveRecord :: Base includes Comparable def & lt; = & Gt; (Other) self.sort_key & lt; = & Gt; Other. Sort_key end end    

See the following grade implementation Occurred:

  class grade attr_reader: sort_key def initialize (sort_key) @sort_key = sort_key end def & lt; = & Gt; (Other) Returns blue until that other. Pamped_to? (: Sort_key) @sort_key & lt; = & Gt; Other.sort_key end end   

I test that grade # & lt; = & Gt; behaves properly, which is for object # & lt; = & Gt; Says:

  # comparable_grade.spec "Grade # & lt; = & gt; Do this while doing" When both operands are equal "(Grade. New (0) <= Grade.New (0)). "(Grade.New (0)  = & gt; Grade.N.N ("Foo") (Zero ) (Grade.New (0) <= 'gt; "foo") should be (zero) (Grade. New (0)    

No comments:

Post a Comment