Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust location definitions #93

Merged
merged 3 commits into from
Jan 9, 2025
Merged

Conversation

kaspth
Copy link
Owner

@kaspth kaspth commented Dec 20, 2024

Say you had this Oaken seed file:

users.create :kasper, name: "Kasper"

We want users.method(:kasper) to point back to that file and line to help debugging.

However, we had a hardcoded db/seeds in our detection, which meant that create/upsert/label in tests would fail on a NoMehodError because our find wouldn't return anything.

In tests, labels make less sense in general, so I'm thinking we should allow those.

I'm also thinking I should try to more sharply define the preparation phase versus the running phase.

The preparation phase: loading and executing db/seeds.rb, setup defaults, helpers and common records
The running phase: when running tests, you shouldn't mutate anything really, and labels shouldn't suddenly spring up, generally things should be deterministic.

Oaken.preparing?/Oaken.running? may be on the table too. Note: this does get complicated if people are using seed "cases/pagination" with one-off seeds. Hm.

Anyway, I'm detecting the path via a quirk on the label + our loading so we don't need to use lookup_paths at all. I'm not sure I'm liking any of this.

@kaspth kaspth self-assigned this Dec 20, 2024
kaspth added 2 commits January 9, 2025 02:23
Say you had this Oaken seed file:

```ruby
users.create :kasper, name: "Kasper"
```

We want `users.method(:kasper)` to point back to that file and line to help debugging.

However, we had a hardcoded db/seeds in our detection,
which meant that create/upsert/label in tests would fail on a NoMehodError because our `find` wouldn't return anything.

In tests, labels make less sense in general, so I'm thinking we should allow those.

I'm also thinking I should try to more sharply define the preparation phase versus the running phase.

The preparation phase: loading and executing db/seeds.rb, setup defaults, helpers and common records
The running phase: when running tests, you shouldn't mutate anything really, and labels shouldn't suddenly spring up, generally things should be deterministic.

`Oaken.preparing?`/`Oaken.running?` may be on the table too.
Note: this does get complicated if people are using `seed "cases/pagination"` with one-off seeds. Hm.

Anyway, I'm detecting the path via a quirk on the label + our loading so we don't need to use `lookup_paths` at all.
I'm not sure I'm liking any of this.
@kaspth kaspth force-pushed the more-robust-location-definitions branch from b922f3d to c81d9a5 Compare January 9, 2025 01:23
@kaspth kaspth force-pushed the more-robust-location-definitions branch from c3f15be to 2f7b4d8 Compare January 9, 2025 01:30
@kaspth kaspth merged commit 191e46b into main Jan 9, 2025
5 checks passed
@kaspth kaspth deleted the more-robust-location-definitions branch January 9, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant