First thing I'd do is add a logger to see what's going on. When you connect to the database, pass a Hash as a 2nd parameter with key :logger and a Logger instance, similar to this:
require "logger" Sequel.connect "sqlite:memory", :logger => Logger.new(STDERR) then check the log! You'll see each statement logged there, which may help identify the problem. Bye, François Le 2011-05-25 à 07:01, Iain Barnett a écrit : > Hi, > > I'm having a go at using the Model stuff by converting some existing > (working) DBI code to use it and running it through RSpec I get this error: > > Failures: > > 1) Tweet save > Failure/Error: t.from_user_id_str = user_id.to_s > NoMethodError: > undefined method `from_user_id_str=' for #<Tweet @values={}> > > > I'm using an in-memory Sqlite3 database for the tests. I've tried various > combinations of things, adding a schema to the class or not, creating the > table prior to the tests or not. I can fill the table with test data using << > (confirmed through logging). I must be missing something but I'm stuck. > > > Here's some code: > > > class Tweet < Sequel::Model(Repository.db[:tweets]) > > set_schema do > primary_key :tweets_id # my auto increment id > Bigint :id, null: false #twitter's tweet id > Integer :from_user_id > String :from_user, null: false > String :profile_image_url > Date :created_at, null: false, default: DateTime.now > String :text_of, null: false > String :iso_language_code, size: 2 > String :source, size: 160 > String :signature, size: 64 > end > > create_table unless table_exists? > > def before_create > self.signature ||= Digest::SHA2.hexdigest( self.text_of ) > super > end # def > end > > and in RSpec: > > describe Tweet do > # before{ Setup.tweets } #creating the table before seems to make no > difference > # I can also fill it with data fine, so I know it's there and works > # after{ Repository.db.drop_table :tweets } > > let(:user_id) { rand(1000_000_000) } > let(:tweet) { > Tweet.new do |t| > t.from_user_id_str = user_id.to_s > t.profile_image_url = > "http://a2.twimg.com/profile_images/123456789/IMG12345-67890123-4567_normal.jpg" > t.created_at = "Thu, 17 Mar 2011 20:10:14 +0000" > t.from_user = "iain_mk2" > t.text_of = ""You are the light. The calm in the day." > That Stephen Malkmus knows how to write a lyric." > t.id = rand(100_000_000_000_000_000) > t.from_user_id = user_id > t.source = "<a href="http://blackberry.com/twitter" > rel="nofollow">Twitter for BlackBerry\\u00ae</a>" > end > } > > subject { ... } # doesn't matter what is run here > end # Tweet > > > Any help is much appreciated. > > Regards, > Iain -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com. To unsubscribe from this group, send email to sequel-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.