[rspec-users] Verify Order
godfoca at gmail.com
Thu Mar 4 01:15:34 EST 2010
Assuming Project.tasks has :order => 'position ASC' then:
describe Project do
@project = Project.create
@first_task = @project.tasks.create(:position => 1)
@last_task = @project.tasks.create(:position => 2)
it "returns its tasks in order" do
@project.tasks.should == [@first_task, @last_task]
Will check that they are ordered.
On Thu, Mar 4, 2010 at 4:03 AM, Frank Lakatos <me at franklakatos.com> wrote:
> I may be missing something obvious, but how do I verify sort order?
> I have
> class Project < ActiveRecord::Base
> has_many :tasks, :order => "position"
> I create a project, and 2 tasks: one with position = 1 and the other with
> position = 2. I want to verify that Project.tasks orders the tasks so that
> the task with position = 1 comes before the task with position = 2.
> Little push would be great, thanks
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users