Skip to content

Commit

Permalink
Use rake to invoke rake tasks, not rails (#130)
Browse files Browse the repository at this point in the history
The documentation for tomo's `rake` helper, and the intent of that
method, is that it runs `bundle exec rake`. However this `rake` helper
was in fact running `bundle exec rails` instead. This was a mistake.

Fix this so that the `rake` helper, and tasks that depend on it (e.g.
`rails:db_migrate`, `rails:db_seed`, etc.) use `bundle exec rake`
instead of `bundle exec rails` as originally intended.

This also makes tomo compatible with older versions of Rails, before the
`rails` was smart enough to be able to invoke rake tasks.
  • Loading branch information
mattbrictson authored May 13, 2020
1 parent 214f3ce commit 88e9d75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tomo/plugin/rails/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def rails(*args, **opts)
end

def rake(*args, **opts)
prepend("exec", "rails") do
prepend("exec", "rake") do
bundle(*args, **opts)
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/tomo/plugin/rails/helpers_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "test_helper"
require "tomo/plugin/rails"

class Tomo::Plugin::Rails::HelpersTest < Minitest::Test
def test_rake_runs_bundle_exec_rake_in_current_path
tester = Tomo::Testing::MockPluginTester.new(
"bundler", "rails", settings: { current_path: "/app/current" }
)
tester.call_helper(:rake, "db:migrate")
assert_equal(
"cd /app/current && bundle exec rake db:migrate",
tester.executed_script
)
end
end

0 comments on commit 88e9d75

Please sign in to comment.