[Rspec-devel] ActiveRecord fixtures support in RSpec
aslak.hellesoy at gmail.com
Fri Apr 28 01:24:09 EDT 2006
> context 'Empolyee' do
> fixtures :employees
> specify 'should have name' do
> employees(:aslak).name.should.equal 'aslak'
I've checked in some experimental code that implements this.
it all lives on the branches/ar_fixtures_facade branch.
I have been able to reuse about ~75% of the whole fixtures code, which
is the functionality that loads fixture files (yml, csv etc.) and
populates database tables.
The remaining ~25% of the Rails fixtures code that defines the
'fixtures' and dynamic helper methods (like employees) have been
copied, tweaked and moved to Context, Specification and
ExecutionContext extensions. Even if this had been implemented better
in Rails it would have been hard to reuse. I don't think it's that big
a deal. There is about 150 lines of code to reimplement.
I'm eager to get some feedback on this - especially from people who
know rails fixtures internals.
More information about the Rspec-devel