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

Do not crash when trying to generate DSL RBIs on non-rails apps #847

Merged
merged 2 commits into from
Mar 9, 2022

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented Mar 9, 2022

Motivation

Avoid getting a scary stack trace when running tapioca dsl in the wrong kind of app:

$ bundle exec tapioca dsl
Loading Rails application... Done
Loading DSL compiler classes... Done
Compiling DSL RBI files...

bundler: failed to load command: tapioca
tapioca/lib/tapioca/dsl/compilers/url_helpers.rb:112:in `gather_constants': undefined method `routes' for nil:NilClass (NoMethodError)

Implementation

Check if we are in a Rails app with Rails.application.

Signed-off-by: Alexandre Terrasa <[email protected]>
Co-authored-by: Ufuk Kayserilioglu <[email protected]>
@Morriar Morriar added the bugfix label Mar 9, 2022
@Morriar Morriar requested a review from a team March 9, 2022 19:55
@KaanOzkan
Copy link
Contributor

Looks like there's need to update a test expectation @Morriar

Signed-off-by: Alexandre Terrasa <[email protected]>
Co-authored-by: Ufuk Kayserilioglu <[email protected]>
@Morriar Morriar force-pushed the at-uk-do-not-crash-on-non-rails-app branch from 74389c7 to 9ec7826 Compare March 9, 2022 21:28
@vinistock
Copy link
Member

Should we print a message when we don't have a Rails application? My understanding of what will happen is that we're simply not going to process any constants, but maybe we could print a message saying DSL generators are not yet supported for non-Rails applications.

@Morriar
Copy link
Collaborator Author

Morriar commented Mar 9, 2022

Should we print a message when we don't have a Rails application?

We have a WIP branch to support non-rails application, it should be supported "soon", at least before Tapioca 1.0 is out ⛵

@Morriar Morriar merged commit e939a79 into main Mar 9, 2022
@Morriar Morriar deleted the at-uk-do-not-crash-on-non-rails-app branch March 9, 2022 21:42
@@ -8,8 +8,8 @@ module Dsl
module Compilers
class ActiveRecordFixturesSpec < ::DslSpec
describe "Tapioca::Dsl::Compilers::ActiveRecordFixtures" do
describe "initialize" do
it "gathers only the ActiveSupport::TestCase base class" do
describe "without a Rails app" do
Copy link
Member

Choose a reason for hiding this comment

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

🙏

paracycle pushed a commit that referenced this pull request Mar 29, 2022
Do not crash when trying to generate DSL RBIs on non-rails apps
@paracycle paracycle added the backported Backported to stable branch label Apr 29, 2022
@shopify-shipit shopify-shipit bot temporarily deployed to production May 13, 2022 23:08 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Backported to stable branch bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants