- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Revamp the minitesting
bundled configuration so it uses Rack::Test
#954
Open
jaredcwhite
wants to merge
11
commits into
main
Choose a base branch
from
update-minitesting-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+619
−497
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…d the Roda server
radanskoric
added a commit
to radanskoric/masterhotwire
that referenced
this pull request
Dec 16, 2024
It supports testing static pages and Roda routes with the same setup. I extracted it from bridgetownrb/bridgetown#954 With Jared's advice he gave me in Discord.
- also add "intuitive" expectations like `expect(something) == "to equal this"` - remove RSpec Mocks library and replace with Minitest mocks and stubs
Ooo, this is worth looking into: |
transition some "shoulda" style tests to Minitest spec syntax
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At this juncture, I'd say it really makes the most sense to do automated testing at the Rack level so you can test both static routes (post site build) and dynamic routes, all via the Roda server application under the hood.
This PR updates the
minitesting
bundled configuration, as well as adds a canonical boot sequence and Minitest-basedBridgetown::Test
superclass that test files can subclass. I'm backing out of "shoulda" etc. in favor of standard test definitions, and the old Rails DOM Assertions stuff is gone entirely in favor of Nokolexbor, mirroring how the HTML Inspectors feature works. I think this is much cleaner overall, and provides for really nice static+dynamic test ergonomics.We'll eventually want to double-check this works nicely with the Bridgetown Sequel gem as well.
Resolves #570
Addendum: I also added support for Minitest expectations to Bridgetown tests — that's the syntax where you can say
expect([1,2,3]).must_include(2)
. I'm starting to like that more thanassert_
now that I've been spending time with it. In fact, I went a step further with some custom extensions so you can write "intuitive" expectations likeexpect(something) == "to equal this"
. Whoa!As part of these changes, I removed the RSpec Mocks library and replaced with Minitest mocks and stubs.
Update 2: Well, this has become quite the rabbit hole. I ended up extending the Spec DSL fully into the base test classes, allowing the use of
describe
,before
/after
, andit
. This effectively lets us migrate away from the "shoulda" gem, becausecontext
,setup
andshould
essentially map 1:1 with the Spec DSL. Once we transition, we can remove the shoulda gem dependency entirely and rely on "vanilla" Minitest functionality. 😎