[rspec-devel] [ rspec-Bugs-8991 ] Fixtures not loading from spec_helper
noreply at rubyforge.org
noreply at rubyforge.org
Sun Mar 4 06:51:56 EST 2007
Bugs item #8991, was opened at 2007-03-02 23:34
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8991&group_id=797
Category: rails plugin
Group: None
Status: Open
Resolution: Rejected
Priority: 3
Submitted By: Simon Harris (haruki_zaemon)
Assigned to: David Chelimsky (dchelimsky)
Summary: Fixtures not loading from spec_helper
Initial Comment:
When I load fixtures from spec_helper.rb I get
NoMethodError in 'The Source File model should be valid when name and content root are present and unique'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
However all the tests pass when I load the fixtures from the specs.
I'd rather not use fixtures but I've converted an entire application from standard rails tests to specs.
----------------------------------------------------------------------
>Comment By: Simon Harris (haruki_zaemon)
Date: 2007-03-04 22:51
Message:
Oh. One more thing. I had a look at the generator and
although the commented out example has the correct syntax,
for a doofus like me the comment:
# can do it in individual contexts using "fixtures :table_a,
table_b".
Should probably be
# can do it in individual contexts using
"self.global_fixtures :table_a, table_b".
Cheers,
Simon
----------------------------------------------------------------------
Comment By: Simon Harris (haruki_zaemon)
Date: 2007-03-04 22:49
Message:
Worked like a charm. I didn't see the self.global_fixtures
change. My apologies. I did look on the upgrade page so an
update to that would no-doubt help others.
Keep up the great work. Love it!
----------------------------------------------------------------------
Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-04 16:01
Message:
I've verified that this works correctly if you update the spec_helper and assign your global fixtures like this:
module Spec
module Rails
module Runner
class EvalContext < Test::Unit::TestCase
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
self.fixture_path = RAILS_ROOT + '/spec/fixtures'
self.global_fixtures = :table_a, :table_b
end
end
end
end
I need to add something about this to the upgrade page. I'll leave this open until that is done.
David
----------------------------------------------------------------------
Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-03 07:06
Message:
Did you run script/generate rspec? spec_helper.rb changed in 0.8. You now identify global_fixtures there and/or local fixtures in each spec.
Give that a shot and pls let me know if that does the trick.
Cheers,
David
----------------------------------------------------------------------
Comment By: Simon Harris (haruki_zaemon)
Date: 2007-03-03 07:01
Message:
My apologies (I shouldn't post when it's late). Version is
0.8.0. Thanks.
----------------------------------------------------------------------
Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-02 23:59
Message:
version please
----------------------------------------------------------------------
Comment By: Simon Harris (haruki_zaemon)
Date: 2007-03-02 23:49
Message:
No, actually now that the errors have been resolved, the
original problem persists.
----------------------------------------------------------------------
Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-02 23:48
Message:
version?
----------------------------------------------------------------------
Comment By: Simon Harris (haruki_zaemon)
Date: 2007-03-02 23:45
Message:
Update: Actually what was happening is that errors
encountered while loading the fixtures were being
surpressed. So I'd suggest that be fixed but in general the
fixtures loading is working as advertised.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8991&group_id=797
More information about the rspec-devel
mailing list