Hello, Jeremy!

What if I need to return two records and then calculate an average for it?

I used this way
ds = Sequel.mock[:t].with_fetch([{:x=>1}, {:x=>3}])
but ds.avg(:x) returns 1.

Do I need to write a monkey patch for this method for my tests?

среда, 21 декабря 2011 г., 8:47:33 UTC+11 пользователь Jeremy Evans написал:
>
> On Dec 20, 6:09 am, Alex Sergeyev <[email protected]> wrote: 
> > Hi, 
> > 
> > How to setup columns and values for Dataset mock? 
> > DB = Sequel.mock 
> > DB[:items].all => [{:id => 1, :name =>2}] 
> > DB[:foo].all => [{:id => 1, :foo =>25}] 
>
> Did you read the RDoc for the mock adapter (http:// 
> sequel.rubyforge.org/rdoc-adapters/classes/Sequel/Mock.html)?  This is 
> a serious question, because if you did and you still don't understand 
> how to use it, the RDoc needs to be improved.  Here's an example: 
>
>   # When initializing the Database 
>   DB = Sequel.mock(:fetch=>[{:id => 1, :name =>2}]) 
>
> or: 
>
>   # After initializing the Database 
>   DB.fetch = [{:id => 1, :name =>2}] 
>
> or: 
>
>   # Override per dataset 
>   ds = DB[:items] 
>   ds._fetch = [{:id => 1, :name =>2}] 
>
> Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to