Thanks to all of you who replied.

It looks like the most common pattern for this is to do the black-box
testing actually creating the data.

This is what I usually end-up doing. But it has always been smelling bad to
me.

In any case, so far there doesn't seem to be a better approach and I guess
I'll continue doing it the "smelly" way :)


Cheers,
Dmytrii

On 15 August 2012 13:20, Andrew Grimm <[email protected]> wrote:

> Bikeshedding from a non-Rails developer here, but rather than seeing
> if two items are sorted correctly, you could specify that one object
> is treated as coming before another object
>
> object1.should < object2
>
> or
>
> sorting(object1, object2).should eq -1
>
> It might make it easier to read.
>
> Andrew
>
> On Wed, Aug 15, 2012 at 10:13 AM, Gregory McIntyre
> <[email protected]> wrote:
> > I agree with Paul and David. I would use strategy (2) with Machinist'd
> > data or stubs.
> >
> > 1. Set up two items, out of order.
> > 2. Assert ordered(items) swaps them.
> >
> > If you are concerned about further cases such as numerical sorting
> > versus string sorting, or edge cases, then put those in too, but
> > David's code looks good to me, as a minimum check.
> >
> > My only addition is that sometimes I stick a .map(&:name) on the end
> > of my subject to make the output nicer.
> >
> > describe OrderedFooList
> >   let(:shorts) { stub(:name => "Shorts") }
> >   let(:socks) { stub(:name => "socks") }
> >
> >   describe '#ordered' do
> >     subject { OrderedFooList.new(input).ordered.map(&:name) }
> >     context 'when given socks and Shorts in that order' do
> >       let(:input) { [socks, shorts] }
> >       it { should == ['Shorts', 'socks'] }
> >     end
> >   end
> > end
> >
> > -Greg
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ruby or Rails Oceania" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected].
> > For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to