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) end
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: #{sub_plan.publication.errors}" assert_equal sub_plan.publication_id, pub.id
assert_valid sub_plan, "errors: #{sub_plan.errors.to_yaml}" end
private # just a little util method to create a record with the necessary parameters def create(h={}) SubscriptionPlan.create({ :price => 55.25, :duration_in_months => 17, :publication => @gold, :active => false }.merge(h)) end end
And here are the test results:
4) Failure: test_should_make_sure_record_can_be_created(SubscriptionPlanTest) [./../test_helper.rb:33:in `assert_valid' subscription_plan_test.rb:19:in `test_should_make_sure_record_can_be_created']: errors: --- &id002 !ruby/object:ActiveRecord::Errors base: !ruby/object:SubscriptionPlan attributes: price: 55.25 duration_in_months: 17 deleted_at: publication_id: 1 active: false errors: *id002 new_record: true publication: &id001 !ruby/object:Publication attributes: long_name: J. Taylor's Gold & Technology Stocks id: "1" version: "1" short_name: gold errors: !ruby/object:ActiveRecord::Errors base: *id001 errors: {}
errors: publication: - is invalid . <false> 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? fails...
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 instead. (in /Users/smtlaissezfaire/devel/rails/subscription_manager/vendor/rails/activerecord) 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 Started .........F.................................................................................................................................F.. 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 <nil>.
2) Failure: test_utc_as_time_zone(BasicsTest) [base_test.rb:662]: <Sat Jan 01 05:42:00 UTC 2000> expected but was <nil>.
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