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

feat: access Roda routes directly in console via Rack Test #953

Open
jaredcwhite opened this issue Dec 7, 2024 · 0 comments
Open

feat: access Roda routes directly in console via Rack Test #953

jaredcwhite opened this issue Dec 7, 2024 · 0 comments
Milestone

Comments

@jaredcwhite
Copy link
Member

We have a --server-config option for the console command to load the full Roda stack, but we don't actually have an obvious way of testing routes in the console. I spent some time playing around with getting Rack Test loaded, and it turns out to be surprisingly easy!

gem "rack-test" # add this to your Gemfile

# then when you run `bin/bridgetown console --server-config`:

require "rack/test"
IRB::ExtendCommandBundle.include Rack::Test::Methods
def app = RodaApp.app

get '/'

doc = Nokolexbor::Document.parse get("/").body
doc.query_selector("h2").inner_html # inspect your response

get("/preview/docs/_docs%2Findex.md").body # => test a dynamic server route

I think what we should do is add conditional code in the console command for the server boot where, if the "rack-test" gem is available, we set up these commands. If not, no worries! Then we can add documentation for folks to add "rack-test", and also it can be part of our overall Minitest bundled configuration aka #570.

@jaredcwhite jaredcwhite added this to the 2.0 milestone Dec 7, 2024
@jaredcwhite jaredcwhite modified the milestones: 2.0, 2.1 Dec 22, 2024
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

No branches or pull requests

1 participant