-
Notifications
You must be signed in to change notification settings - Fork 440
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 using view components in rails engine #1951
Add support for using view components in rails engine #1951
Conversation
👋 Just a quick nudge to say #1308 means you'll need to rebase this branch for checks to pass. |
2c551bf
to
3ba0a7c
Compare
18c846c
to
1910a72
Compare
First step to add support for using view components in rails engine
1910a72
to
5c16496
Compare
There is problem with tests for |
@tkowalewski we have fixed the rails main issues, and added support for ruby head as a bonus aswell |
@tkowalewski would you be up for fixing the failing tests on this PR? It seems like you're pretty close ❤️ |
@joelhawksley Ready :) |
Rakefile
Outdated
end | ||
|
||
Rake::TestTask.new(:engine_test) do |t| | ||
t.libs << "test/dummy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.libs << "test/dummy" | |
t.libs << "test/engine" |
👋🏻 I have a slight aversion to using the term dummy
, might you be willing to change the naming to engine
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, engine
is something like keyword for rails I think.
If we want to rename test engine to engine
- we will have weird naming I think. For eg. test engine will look like:
module Engine
class Engine < ::Rails::Engine
isolate_namespace Engine
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe test_engine
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or example
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to TestEngine
Instead of wraping test/spec with module namespacing pass module namespace inline with described class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! ❤️
What are you trying to accomplish?
I'm trying to add support for generating view components in the module (engine) namespace in rails engine.
To do it we need to wrap templates code with
module_namespacing
(provided by rails)How to test
Update gemspec (
engine_with_test.gemspec
)Update
spec.homepage
Update
spec.summary
Update
spec.description
Update
spec.metadata["source_code_uri"]
Update
spec.metadata["changelog_uri"]
Add view_component to
Gemfile
app/components/engine_with_test/example_component.html.erb
)Uncomment test (
test/components/engine_with_test/example_component_test.rb
)Run tests
and go to
http://localhost:3000/rails/view_components
What approach did you choose and why?
There is only one solution to deliver view components for rails engine with module (engine) namespace: Wrap templates code with
module_namespacing
:)Anything you want to highlight for special attention from reviewers?
test/test_engine
)engine_test
) was added to Rakefile