[rspec-users] Testing arbitrary SQL

Rodrigo Alvarez Fernández papipo at gmail.com
Mon Aug 27 15:34:56 EDT 2007


On 8/27/07, Courtenay <court3nay at gmail.com> wrote:
> You create the records.

I guess that I need to hit the database to really test if the method
is working at all.
In fact what I must test is the SQL query itself.

Thanks.

>
>   @bah = Bah.create!
>   [1, 5, 22, 16].each { |amount| Foo.create! :amount => amount, :bah => @bah }
>
>   @bah.foos.should == 44
>
>
> On 8/27/07, Rodrigo Alvarez Fernández <papipo at gmail.com> wrote:
> > Hi,
> >
> > I would like to know how would you test a method in a model that uses
> > complex a SQL query that joins several tables in order to make a
> > calculation.
> >
> > I suppose that I need fixtures, although my approach with rspec is to
> > avoid fixtures and isolate model specs, but none of both seems
> > possible in this case. Is there another way than fixtures?
> >
> > Thanks.
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list