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

Add support for Rails engines routes in request specs #2372

Merged
merged 6 commits into from Aug 27, 2020
Merged

Add support for Rails engines routes in request specs #2372

merged 6 commits into from Aug 27, 2020

Conversation

drwl
Copy link
Contributor

@drwl drwl commented Aug 20, 2020

Currently, when scaffolds are generated inside a Rails Engine, it generates requests specs that fail without modification. This happens because the Engine routes are not mounted under Rails.application.

To fix this, Engine routes have to be included so that url and path helpers can be usable from within the spec file.

@pirj pirj changed the title Update request spec scaffold template Add support for Rails engines routes in request specs Aug 20, 2020
@pirj
Copy link
Member

pirj commented Aug 20, 2020

I guess we'll need a spec for that.

@JonRowe JonRowe linked an issue Aug 24, 2020 that may be closed by this pull request
@JonRowe
Copy link
Member

JonRowe commented Aug 24, 2020

Great start thanks for tackling, we usually test generators by running them in the example app, tweaking with removing comments etc and then letting them pass

@drwl
Copy link
Contributor Author

drwl commented Aug 25, 2020

Thanks for the feedback everyone. I was trying to get a reproducable test case so have been working on that.

Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

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

I like the additional documentation, but it doesn't test the generator, that still needs to be added ideally.

features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
features/request_specs/engine_named_routes.feature Outdated Show resolved Hide resolved
Currently, when scaffolds are generated inside a Rails Engine, it generates requests specs that fail without modification. This happens because the Engine routes are not mounted under Rails.application.

To fix this, Engine routes have to be included so that url and path helpers can be usable from within the spec file.
@drwl drwl requested a review from JonRowe August 26, 2020 17:14
@drwl
Copy link
Contributor Author

drwl commented Aug 26, 2020

@JonRowe I've added a test to make sure the route helpers get included. Wanted to get your thoughts on the namespaced include engine route/url helpers -- it looks like Rails generators does not do that, so does it make sense to keep it similar?

@JonRowe JonRowe merged commit 2379212 into rspec:main Aug 27, 2020
JonRowe added a commit that referenced this pull request Aug 27, 2020
@pirj
Copy link
Member

pirj commented Aug 27, 2020

Thanks!

This was referenced Mar 15, 2021
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.

Add support for Rails engines routes in request specs
4 participants