Hi @kaspth,
I've completed converting my demo data and baseline test data (i.e., the test uses in almost every test) to Oaken. It was mostly uneventful and now my tests are about 3x faster Vs. FactoryBot. So, over all, a huge win already.
My configuration so far:
- I am relying on 'setup' being auto loaded per the docs, so I have a top level setup.rb, and then db/seeds/setup/* with several files (for organization and to make it clear where each kind of data is created).
- I also have db/seeds/test/setup/* to load my baseline (expected for almost every test) test data. This loads automatically as expected when I run a test or the test suite.
Questions:
- Is db/seeds.rb with
Oaken.seed the correct entry point into Oaken?
- Is my assumptive use of db/seeds/test/setup/* is (the / a) correct way to load baseline test data?
- The way oaken caches is a little opaque and I ran into the following. I have an oaken object
users.provider_user. When I attempted to add a role to it via either users.provider_user.roles.build(...) or users.provider_user.roles << Roles.new(...) it would not accept the roles (i.e., user.provider_user would show no roles). But when I did provider = users.provider; provider.roles.build(....) everything worked. I'm sure this is yet another Ruby subtly that I'm about the get schooled on, but I'm a little flummoxed.
Issues:
Using RSpec, I have included require `oaken/rspec' in my rails_helper.rb that's required by every test. However when I have test specific Oaken files and call it via before { 'models/active_sesssion' } what I'm seeing is the before block is attempting to reload the baseline setup test data referenced above (causing an error). So clearly I didn't understand something in the docs and my configuration is incorrect. I'm at a loss for how to have both generic baseline test data and test specific test data.
Feedback:
While developing Oaken data across several files and fumbling my way around trying to learn what does and does not work, I would hit errors in the data creation (order or syntax). Unfortunately, Oaken swallows many of the errors and simply returns the top level object that initialized the Oaken load (in my case db/seed.rb with the ```Oaken.seed```` line) as being invalid. This meant that I had to resort to commenting out files/lines and/or puts debugging.
The more details for error reporting the better. Best would be file and line #, but at least the specific file that's at issue would help a lot.
Thanks,
@hms
Hi @kaspth,
I've completed converting my demo data and baseline test data (i.e., the test uses in almost every test) to Oaken. It was mostly uneventful and now my tests are about 3x faster Vs. FactoryBot. So, over all, a huge win already.
My configuration so far:
Questions:
Oaken.seedthe correct entry point into Oaken?users.provider_user. When I attempted to add a role to it via eitherusers.provider_user.roles.build(...)orusers.provider_user.roles << Roles.new(...)it would not accept the roles (i.e., user.provider_user would show no roles). But when I didprovider = users.provider; provider.roles.build(....)everything worked. I'm sure this is yet another Ruby subtly that I'm about the get schooled on, but I'm a little flummoxed.Issues:
Using RSpec, I have included
require `oaken/rspec'in my rails_helper.rb that's required by every test. However when I have test specific Oaken files and call it viabefore { 'models/active_sesssion' }what I'm seeing is the before block is attempting to reload the baseline setup test data referenced above (causing an error). So clearly I didn't understand something in the docs and my configuration is incorrect. I'm at a loss for how to have both generic baseline test data and test specific test data.Feedback:
While developing Oaken data across several files and fumbling my way around trying to learn what does and does not work, I would hit errors in the data creation (order or syntax). Unfortunately, Oaken swallows many of the errors and simply returns the top level object that initialized the Oaken load (in my case db/seed.rb with the ```Oaken.seed```` line) as being invalid. This meant that I had to resort to commenting out files/lines and/or puts debugging.
The more details for error reporting the better. Best would be file and line #, but at least the specific file that's at issue would help a lot.
Thanks,
@hms