Hi Jeremy,

I had successfully make it working but ran into another problem. When I 
calling column of a dataset, it raises a NoMethodError. However, using 
something like data[:name] is fine.

DB = Sequel.mock

DB.create_table(:artists) do
 # Primary key must be set explicitly
 primary_key :id
 String :name
end

DB.create_table(:albums) do
 primary_key :id
 # Table that foreign key references needs to be set explicitly
 # for a database foreign key reference to be created.
 foreign_key :artist_id, :artists
 String :name
end

class Artists < Sequel::Model(:artists)
 one_to_many :albums
end

class Album < Sequel::Model(:albums)
 many_to_one :artists
end

class Tag < Sequel::Model
 many_to_many :albums
end


describe 'Model testing' do

 before do
 ds = Artists.dataset
 ds.columns([:id, :name])
 ds._fetch = [{:id => 1, :name =>'name1'}]
 ds1 = Album.dataset
 # ds.columns([:id, :name])
 ds1._fetch = [{:id => 2,
 :artist_id => 1,
 :name => 'name2'
 }]
 end

 it 'this is a test to test test' do

 data = Artists[:id => 1]

 expect(data.id).to eq(1)
 expect(data.name).to eq ('name1')
 expect(data.albums[0].name).to eq('name2')
 end
end

This give the error:

NoMethodError: undefined method `name' for #<Artists @values={:id=>1, 
:name=>"name1"}>


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