Strange sqlite3 errors - validates_associated & failing acti

I’m getting two strange errors, both which I believe relate to sqlite3.

The first one is with validates associated. Here is my test:

require File.dirname(FILE) + ‘/…/test_helper’

class SubscriptionPlanTest < Test::Unit::TestCase
fixtures :subscription_plans
fixtures :publications

def setup
@six_month_gold = subscription_plans(:six_month_gold)
@gold = publications(:gold)

def test_should_make_sure_record_can_be_created
sub_plan = create
pub = Publication.find(sub_plan.publication_id)
assert_valid pub, “publication errors: #{pub.errors}”
assert_valid sub_plan.publication, “sub_plan.publication.errors:
assert_equal sub_plan.publication_id,

assert_valid sub_plan, "errors: #{sub_plan.errors.to_yaml}"



just a little util method to create a record with the necessary

def create(h={})
:price => 55.25,
:duration_in_months => 17,
:publication => @gold,
:active => false

And here are the test results:

  1. Failure:
    [./…/test_helper.rb:33:in assert_valid' subscription_plan_test.rb:19:intest_should_make_sure_record_can_be_created’]:
    errors: — &id002 !ruby/object:ActiveRecord::Errors
    base: !ruby/object:SubscriptionPlan
    price: 55.25
    duration_in_months: 17
    publication_id: 1
    active: false
    errors: *id002
    new_record: true
    publication: &id001 !ruby/object:Publication
    long_name: J. Taylor’s Gold & Technology Stocks
    id: “1”
    version: “1”
    short_name: gold
    errors: !ruby/object:ActiveRecord::Errors
    base: *id001
    errors: {}


  • is invalid
    is not true.

The test fails on line 19, which is the line:
assert_valid sub_plan, “errors: #{sub_plan.errors.to_yaml}”

Notice that the associated model has already been checked for errors
in the previous assertion in the test, but assert sub_plan.valid?

This lead me to running the unit tests for active record. When I run
the tests through Rake (“rake test_sqlite”), they all pass. But when
running the individual test “base_test.rb”, I obtain failures. Here
is the output:

euclid% rake -I “connections/native_sqlite3” base_test.rb
/opt/local/bin/rake:17:Warning: require_gem is obsolete. Use gem
rake aborted!
Don’t know how to build task ‘base_test.rb’

(See full trace by running task with --trace)
euclid% ruby -I “connections/native_sqlite3” base_test.rb
Using native SQLite3
Loaded suite base_test
Finished in 3.775074 seconds.

  1. Failure:
    test_attributes_on_dummy_time(BasicsTest) [base_test.rb:903]:
    <Sat Jan 01 05:42:00 EST 2000> expected but was

  2. Failure:
    test_utc_as_time_zone(BasicsTest) [base_test.rb:662]:
    <Sat Jan 01 05:42:00 UTC 2000> expected but was

142 tests, 474 assertions, 2 failures, 0 errors

I also have heard of the problems with newer versions of sqlite. Here
are my system specs:

OS: Mac OS X.4
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
rails: edge revision 6139
sqlite3: version 3.3.7

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs