V
Vassilis Rizopoulos
Yes, this is ActiveRecord without Rails again.
Specifically testing with fixtures.
I'm stuck making them work and I know exactly where the code is checking
out and leaving me in the dark.
Now, the following will not load the fixtures and I want to know why.
require 'rubygems'
require 'active_record'
require 'active_record/fixtures'
require 'test/unit'
class Schema<ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.column :txt, :string
end
end
end
class Entry<ActiveRecord::Base
end
class TestFixture<Test::Unit::TestCase
ActiveRecord::Base.establish_connectionadapter =>
"sqlite3",:database =>":memory:")
Schema.up
fixture_path=File.join(File.dirname(__FILE__))
use_instantiated_fixtures=true
fixtures :entries
def test_fixtures
assert_equal(2,Entry.findall).size)
end
end
Use the following in an entries.yml:
new_entry:
txt: "new entry"
old_entry:
txt: "old entry"
I'm using active record 1.15.3. I followed the call chain all the way to
a check in Test::Unit::testCase#setup_with_fixtures.
The first line in that method is
return unless defined?(ActiveRecord::Base) &&
!ActiveRecord::Base.configurations.blank?
and the configurations are ofcourse blank
So what am I missing? Obviously I need to recreate some more of that
Rails magic.
Cheers,
V.-
Specifically testing with fixtures.
I'm stuck making them work and I know exactly where the code is checking
out and leaving me in the dark.
Now, the following will not load the fixtures and I want to know why.
require 'rubygems'
require 'active_record'
require 'active_record/fixtures'
require 'test/unit'
class Schema<ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.column :txt, :string
end
end
end
class Entry<ActiveRecord::Base
end
class TestFixture<Test::Unit::TestCase
ActiveRecord::Base.establish_connectionadapter =>
"sqlite3",:database =>":memory:")
Schema.up
fixture_path=File.join(File.dirname(__FILE__))
use_instantiated_fixtures=true
fixtures :entries
def test_fixtures
assert_equal(2,Entry.findall).size)
end
end
Use the following in an entries.yml:
new_entry:
txt: "new entry"
old_entry:
txt: "old entry"
I'm using active record 1.15.3. I followed the call chain all the way to
a check in Test::Unit::testCase#setup_with_fixtures.
The first line in that method is
return unless defined?(ActiveRecord::Base) &&
!ActiveRecord::Base.configurations.blank?
and the configurations are ofcourse blank
So what am I missing? Obviously I need to recreate some more of that
Rails magic.
Cheers,
V.-