Skip to content

Conversation

@abraham-chan
Copy link
Contributor

Add rule to fix a common Rails issue when running tests.

Rails source code that generates the message: https://github.com/rails/rails/blob/main/activerecord/lib/active_record/migration.rb#L152

Example output on my console:

abrahamchan [master] > bin/rspec     
Running via Spring preloader in process 35661
Migrations are pending. To resolve this issue, run:

        rails db:migrate RAILS_ENV=test
No examples found.

abrahamchan [master] > fuck
rails db:migrate RAILS_ENV=test [enter/↑/↓/ctrl+c]
== 20210627174953 Example: migrating ==========================================
== 20210627174953 Example: migrated (0.0000s) =================================

abrahamchan [master] > bin/rspec
[successful rspec output]

Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

Please consider my sugestion below.

Comment on lines 41 to 42
(Command("", output_env_development), "rails db:migrate RAILS_ENV=development"),
(Command("", output_env_test), "bin/rails db:migrate RAILS_ENV=test"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reviewing it again, I thought that the corrected command could include the one initially intended by the user.

Suggested change
(Command("", output_env_development), "rails db:migrate RAILS_ENV=development"),
(Command("", output_env_test), "bin/rails db:migrate RAILS_ENV=test"),
(Command("bin/rspec", output_env_development), "rails db:migrate RAILS_ENV=development && bin/rspec"),
(Command("bin/rspec", output_env_test), "bin/rails db:migrate RAILS_ENV=test && bin/rspec"),

Make sure to use shell._and to join the commands together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done

@abraham-chan abraham-chan requested a review from scorphus July 5, 2021 04:31
Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

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

Good job, @abraham-chan! Thanks for contributing! :shipit:

@scorphus scorphus merged commit 6111523 into nvbn:master Jul 6, 2021
@scorphus scorphus added this to the 3.32 milestone Jul 18, 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.

2 participants