On Dec 20, 6:14 pm, Alex Sergeyev <[email protected]> wrote:
> Hi, Jeremy
>
> Thanks for reply. I have read the RDoc.
> I have a rake task that executes something like:
>
> def self.perform
>   a = DB[:table1].filter(xxx)
>   b = DB[:table2].filter(yyy)
>   DB[:table3].insert(do_magic(a,b))
> end
>
> I need to mock :table1 and :table2 with different output. I can't
> override _fetch_ between this two calls
> Now I found some solution for that, looks ugly but works :). It will
> be great if you know some correct solution for this problem
>
>   before(:all) do
>      output = Proc.new do |query|
>        case query
>          when /SELECT.*table1/ then {:id => 1, :foo => 5, :bar => 1}
>          when /SELECT.*table2/ then [{:id => 6, :foobar => "xxx"}]
>        end
>      end
>      DB = Sequel.mock(:fetch => output)
>   end

That's the correct usage of the API if you want to vary the fetched
output based on the SQL provided, so if it is working, I wouldn't
change it.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.

Reply via email to