RSpeckers:
I’m asserting that a list should be sorted by affinity. The following
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
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?
–
Phlip
http://www.oreilly.com/catalog/9780596510657/
^ assert_xpath
O'Reilly Media - Technology and Business Training ← assert_latest Model