On Wednesday, March 9, 2016 at 9:49:24 PM UTC-8, Denny Wang wrote:
>
> Hi, I am trying to mock some data for unit testing.
>
> DB = Sequel.mock(:fetch=>[{:id => 1, :name => 'name'}])
> Sequel::Model.db = DB
>
> This is find and I can get the mocked data.
> fetchedData = DB[:fetch].where(:name => 'name')
>
> However, I also have a model:
>
> class FetchSomething < Sequel::Model(:fetch)
>
> I can't retrieve the mocked data then:
>
> fetchedData = :FetchSomething[:name => 'name']
>
> Could someone please point out what I had done wrong or what am I missing?
> Thanks.
>

I can't reproduce your issue: 

$ bin/sequel -E 
Your database is stored in DB...
irb(main):001:0> DB.fetch = [{:id => 1, :name => 'name'}]
=> [{:id=>1, :name=>"name"}]
irb(main):002:0> class FetchSomething < Sequel::Model(:fetch); end
I, [2016-03-09T21:56:35.045716 #12796]  INFO -- : SELECT * FROM fetch LIMIT 
1
I, [2016-03-09T21:56:35.046314 #12796]  INFO -- : SELECT * FROM fetch LIMIT 
1
=> nil
irb(main):003:0> fetchedData = FetchSomething[:name => 'name']
I, [2016-03-09T21:56:40.903413 #12796]  INFO -- : SELECT * FROM fetch WHERE 
(name = 'name') LIMIT 1
=> #<FetchSomething @values={:id=>1, :name=>"name"}>

Thanks,
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