Hi all,
I’m new to this list as well as to engines in general. I am taking my
first
stab at writing an engine and am having a little trouble getting the
tests
for my engine working. Everything else is working at this point, e.g.
controllers, models, migrations, etc. The last step is to get testing
working.
Can I get a general overview on how tests are supposed to work? I’m
using
Rails 1.2.1 and the release branch of Engines 1.2.
Basically, at this point, I copied the tests from the surrounding
application in to my engine’s test folder, so my dir structure looks
like
my_engine
- app
- lib
- …
- test
- fixtures/
- functional/
- integration/
- mocks/
- unit/
- test_helper.rb
Problems I’m having:
1). Fixtures don’t seem to be loading. I read in the docs that I need
to
call Engines::Testing.set_fixture_path first, but a) I couldn’t get it
to
recognize Engines, and b) it looks like the rake plugins:units task does
this for me—I think.
2). I had a file in my engine’s lib folder that I need to include. I
couldn’t get it to include normally. I ended up getting it to work
with:
require File.dirname(FILE) + ‘/…/lib/authenticated_test_helper’
include AuthenticatedTestHelper
where I used to be able to call include AuthenticatedTestHelper by
itself.
Are files in lib not automatically loaded?
3). In my original test_helper.rb there is the TestCase section, where
you
set certain options like self.use_transactional_fixtures, I was unable
to
get this to work. So, right now, I’ve commented them out.
4). What requires should be where? In the original files, there’s
ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) +
“/…/config/environment”)
require ‘test_help’
in test_helper.rb - Do these still need to be in my engine’s
test_helper.rb?
I think that’s about it. Through various tracking down errors, I’ve
managed
to get the tests to run, but am still getting errors whenever my test
calls
up a fixture with something like users(:trey). Because I’ve done so
much
random tweaking, I thought I’d ask what the preferred way is.
Trey