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

Fix rspec-rails gem issues #626

Merged
merged 7 commits into from
Feb 21, 2024
Merged

Fix rspec-rails gem issues #626

merged 7 commits into from
Feb 21, 2024

Conversation

bigchickenwings
Copy link
Contributor

@bigchickenwings bigchickenwings commented Feb 19, 2024

Description:

Currently, cloning this repository, running the setup command, and then running the specs don't work.

Arctic Admin related issues (Caused by rspec-rails):

The system specs don't work as-is. It throws the following error:

ActionView::Template::Error:
   Error: File to import not found or unreadable: arctic_admin/src/scss/main.
             on line 11:1 of app/assets/stylesheets/active_admin.scss
   >> @import 'arctic_admin/src/scss/main';
      ^
# ./app/assets/stylesheets/active_admin.scss:11
# ------------------
# --- Caused by: ---
# SassC::SyntaxError:
#   Error: File to import not found or unreadable: arctic_admin/src/scss/main.
#           on line 11:1 of app/assets/stylesheets/active_admin.scss
#   >> @import 'arctic_admin/src/scss/main';
#      ^
#   ./app/assets/stylesheets/active_admin.scss:11

This happens because we are adding the arctic_admin through package.json instead of adding it as a gem. Therefore, we need to run bundle exec rails assets:precompile before running our specs.

If we move the rspec-rails gem to both the :development and :test environments, this will be done automatically for us, as mentioned by @santib

With these changes, the API will always work on newly-cloned environments, without needing additional setup.


Preview:

Before:

Screenshot 2024-02-19 at 12 29 49

After:

Screenshot 2024-02-19 at 12 28 59

bigchickenwings and others added 3 commits February 18, 2024 11:05
Spring does not support Rails 7.1 and Ruby 3.3,
which are both used in this project.
If you attempt to run a fresh installation of this repo,
the tests won't pass because of the importations:
- As the arctic_admin gem is not initially on the gemfile,
it will cause the system specs to fail.
- We also need to have the `active_admin.js` in order to pass the specs
(and ensure functionality).

Worth mentioning that `arctic_admin/base` already adds `mixins` and `fontawesome`,
so there might be no need to add them manually.
@santib
Copy link
Member

santib commented Feb 19, 2024

Hi @bigchickenwings thanks for the report.

spring

I'm ok removing it. I actually have it completely disabled in my dev env because it brings more problems than solutions to me. If we are going to remove it, there are more places that need to be changed, try doing git grep -i spring to find all places. cc @JulianPasquale @guillermoap

arctic_admin

It works fine for me (and also in the CI). I think you might be missing doing bundle exec rails assets:precompile since we are installing arctic_admin through the package.json instead of the Gemfile. That said, I think it should be called automatically, but seems that there is something off with RSpec cc @PerezIgnacio

@bigchickenwings
Copy link
Contributor Author

bigchickenwings commented Feb 19, 2024

Hi, @santib

Nice catch, I didn't run bundle exec rails assets:precompile. Running it does make the specs pass.

Any reason behind this decision? This is of course a matter of personal preference, but I do prefer to not have to run bundle exec rails assets:precompile on development and test environments 👀

@santib
Copy link
Member

santib commented Feb 19, 2024

but I do prefer to not have to run bundle exec rails assets:precompile on development and test environments 👀

@bigchickenwings yes, it should be ran automatically. Not sure why it's not happening, maybe it's related to the issue I shared above. But it'd be good to fix it (maybe it's a fix in rspec-rails?).

UPDATE:
If we move the rspec-rails gem to the development + test group, we can then use bin/rails spec and it will automatically precompile assets

rspec-rails gem should be in dev and test environment
@bigchickenwings bigchickenwings changed the title Fix arctic_admin and spring gems issues Fix rspec-rails and spring gems issues Feb 19, 2024
@bigchickenwings
Copy link
Contributor Author

@santib done! Thanks for the help 😄

Let me know if there's anything else I should address on this PR.

@santib
Copy link
Member

santib commented Feb 20, 2024

@santib done! Thanks for the help 😄

Let me know if there's anything else I should address on this PR.

Would you mind making 2 separate PRs with the appropriate titles?

One for improving the rspec-rails setup, and the other to remove Spring (also check for more places where it needs to be removed). This way we can review and have conversations on each of them individually and eventually merge them once they are ready without blocking each other. For example the rspec-rails change will probably be easily accepted, the removal of spring may require some discussion.

@bigchickenwings bigchickenwings changed the title Fix rspec-rails and spring gems issues Fix rspec-rails gem issues Feb 21, 2024
@bigchickenwings
Copy link
Contributor Author

@santib updated this one to handle rspec-rails only.

Will be creating the spring one later today 🚀

Gemfile Outdated Show resolved Hide resolved
@santib santib requested a review from a team February 21, 2024 17:24
@santib santib requested a review from a team February 21, 2024 17:39
@santib santib merged commit 451223f into rootstrap:main Feb 21, 2024
3 of 4 checks passed
@santib
Copy link
Member

santib commented Feb 21, 2024

Thanks @bigchickenwings 🙌

bigchickenwings added a commit to bigchickenwings/rails_api_base that referenced this pull request Feb 21, 2024
Fix `rspec-rails` gem issues (rootstrap#626)
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.

3 participants