On Sun, Feb 8, 2009 at 5:48 PM, Phlip <phlip2...@gmail.com> wrote: > RSpeckers: > > I'm asserting that a list should be sorted by affinity. The following
In BDD we say "expecting" instead of "asserting" > code is good enough for government work, but is there some more clever > way to show that each element is equal or less than the previous > element? > > it 'should rank posts by affinity' do > list = @map.sort_frobs_by_affinity > > list[1].affinity.should >= list[1].affinity please use "should be >=" as "should >=" will eventually be deprecated and removed. > list[2].affinity.should >= list[2].affinity > list[3].affinity.should >= list[3].affinity > list[4].affinity.should >= list[4].affinity > end > > Notice I could just write... > > list.map(&:affinity) == list.map(&:affinity) > > ...but it seems that the point of BDD is to make the business logic > obvious, not obscured in programming details, right? Right. I've done stuff like this before: [b,d,a,c].sort_with_special_method.should == [a,b,c,d] Any other patterns out there? David > > -- > Phlip > http://www.oreilly.com/catalog/9780596510657/ > ^ assert_xpath > http://tinyurl.com/yrc77g <-- assert_latest Model > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users