Skip to content

Write out FixturesSpecHelper#290

Merged
bagedevimo merged 1 commit intomasterfrom
write-out-fixtures-spec-helper
May 21, 2025
Merged

Write out FixturesSpecHelper#290
bagedevimo merged 1 commit intomasterfrom
write-out-fixtures-spec-helper

Conversation

@bagedevimo
Copy link
Contributor

Having this helper generate these tests in before the individual test
runs means they are not included any the standard rspec transactional
tests mechanism. This means that if the suite cannot fully complete for
any reason, such as a syntax error, or if the number of create/destroy
is not perfectly matched in a test then the following test run will
fail.

Using let(:x) and before(:each) is best practise, and shouldn't have a
significant effect on test runtimes.

@bagedevimo
Copy link
Contributor Author

@tom93 keen to know if you any objections to this idea, before I continue through and do the rest of the tests :)

@tom93
Copy link
Contributor

tom93 commented Apr 22, 2025

I'm not that familiar with rspec, but having the second test run be independent sounds like a pretty good idea!
It would be good to check the performance impact.

Small clarifications:

Having this helper generate these tests in before the individual test

Do you mean generate these fixtures/models?

Using let(:x) and before(:each)

I'm a little confused, it seems like this PR is removing uses of before(:each).

@tom93
Copy link
Contributor

tom93 commented Apr 22, 2025

Using let(:x) and before(:each)

I'm a little confused, it seems like this PR is removing uses of before(:each).

Do you mean that before(:all) is bad, and let/before(:each) are good? (I see that a bare "before" is the same as before(:each), and "let" seems like a lazy version of before(:each) so basically interchangeable.)

@Holmes98
Copy link
Member

Do you mean that before(:all) is bad, and let/before(:each) are good?

Yeah, I think that's the intention (was discussed briefly on Discord: https://discord.com/channels/670126531489824788/678154623571329025/1363084851737137272)

@bagedevimo
Copy link
Contributor Author

bagedevimo commented Apr 22, 2025

Yes, clearly I needed to read my commit message better. let(:x) is a preferred mechanism to assigning an ivar in a before block, (https://www.betterspecs.org/#let). One big reason its better is that it has much clearer / more obvious declarations, especially when you use nested contexts.

Yes, before do and before(:each) do are the same thing. Just a more common way of writing it.

Having this helper generate these tests in before the individual test

Yes, this was supposed to read models. Will update soon.

@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch 2 times, most recently from 648cb02 to 4672e9e Compare April 23, 2025 10:13
@bagedevimo
Copy link
Contributor Author

I have updated the commit message, but I haven't copied it back into the GH PR description yet.

@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from 4672e9e to f5a4b49 Compare May 9, 2025 20:01
@bagedevimo bagedevimo changed the base branch from master to graphite-base/290 May 9, 2025 20:19
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from f5a4b49 to 1875470 Compare May 9, 2025 20:19
@bagedevimo bagedevimo changed the base branch from graphite-base/290 to seeds May 9, 2025 20:19
Copy link
Contributor Author

bagedevimo commented May 9, 2025

@bagedevimo bagedevimo changed the base branch from seeds to graphite-base/290 May 9, 2025 20:26
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from 1875470 to 4ce2ff0 Compare May 9, 2025 20:26
@bagedevimo bagedevimo changed the base branch from graphite-base/290 to formats-and-routes May 9, 2025 20:26
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from 4ce2ff0 to 8a3725d Compare May 9, 2025 21:00
@coveralls
Copy link

coveralls commented May 9, 2025

Coverage Status

coverage: 37.513% (-0.2%) from 37.743%
when pulling b48f347 on write-out-fixtures-spec-helper
into 0e0fec6 on master.

@bagedevimo bagedevimo force-pushed the formats-and-routes branch 2 times, most recently from ea518a6 to 2a598e6 Compare May 9, 2025 21:40
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch 2 times, most recently from f4e1438 to 41073c0 Compare May 9, 2025 23:17
@bagedevimo bagedevimo changed the title WIP: Write out FixturesSpecHelper Write out FixturesSpecHelper May 9, 2025
@bagedevimo bagedevimo marked this pull request as ready for review May 9, 2025 23:20
@bagedevimo bagedevimo force-pushed the formats-and-routes branch from 2a598e6 to 8a3e0ff Compare May 16, 2025 23:06
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from 41073c0 to f6ff75b Compare May 16, 2025 23:08
@bagedevimo bagedevimo changed the base branch from formats-and-routes to graphite-base/290 May 18, 2025 13:07
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from f6ff75b to 9078bba Compare May 18, 2025 13:07
@graphite-app graphite-app bot changed the base branch from graphite-base/290 to master May 18, 2025 13:08
Having this helper generate these records before the test suite runs
means they are not included any the standard rspec transactional tests
mechanism. This means that if the suite cannot fully complete for
any reason, such as a syntax error, or if the number of create/destroy
is not perfectly matched in a test then the following test run will
fail.

Using let(:x) and before is best practise, and shouldn't have a
significant effect on test runtimes.
@bagedevimo bagedevimo force-pushed the write-out-fixtures-spec-helper branch from 9078bba to b48f347 Compare May 18, 2025 13:08
Copy link
Member

@Holmes98 Holmes98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is around 10 seconds slower for me (23s vs 13s), but I'm okay with that.

@bagedevimo
Copy link
Contributor Author

This is around 10 seconds slower for me (23s vs 13s), but I'm okay with that.

Huh I might get you to run a profiler at some point as I don't get that change - its within 1s and within the stddev for me.

@Holmes98
Copy link
Member

Holmes98 commented May 21, 2025

@bagedevimo
Copy link
Contributor Author

Hmm you are right - I will dig into that later. I don't think its a blocker, and I am sure I can make it faster again.

@Holmes98
Copy link
Member

Yeah I'm fine with just merging this for now.

@bagedevimo bagedevimo merged commit 1b0fd46 into master May 21, 2025
7 checks passed
@bagedevimo bagedevimo deleted the write-out-fixtures-spec-helper branch May 21, 2025 07:04
@tom93
Copy link
Contributor

tom93 commented May 21, 2025 via email

@tom93
Copy link
Contributor

tom93 commented May 21, 2025 via email

@bagedevimo
Copy link
Contributor Author

Thanks Tom, appreciate you! It could be as simple as we hard-code a passwordhash rather than re-hashing, which I think is a relatively common solution.

@tom93
Copy link
Contributor

tom93 commented May 21, 2025 via email

@Holmes98
Copy link
Member

Nice, can confirm that setting Devise.stretches = 1 fixes it.

Could maybe set that conditionally in the initializer instead of spec_helper, since that's what the Devise currently does in the template:
https://github.com/heartcombo/devise/blob/fec67f98f26fcd9a79072e4581b1bd40d0c7fa1d/lib/generators/templates/devise.rb#L126

But either way works.

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.

4 participants