vendredi 11 août 2017

sort mini test in rails

hi i'm new to rails and i've done a simple sorting of dates in descending order. and now i need to write a test for it. my controller looks like this

def index
 @article = Article.all.order('date DESC')
end

i tried writing a test but it doesnt work this is my code

def setup
@article1 = articles(:one)
end


test "array should be sorted desc" do
    sorted_array = article1.sort.reverse
    assert_equal article1, sorted_array, "Array sorted"
end

Aucun commentaire:

Enregistrer un commentaire