How to run default rake tasks in Rails 5?
up vote
0
down vote
favorite
Here's a layup for someone...
Back in Rails <= 4 days we'd run our test suite by simply typing $ rake
at the command line, thanks to defaults in Rakefile:
task default: [:rubocop, :spec, :teaspoon]
but in Rails 5 it's not so apparent how to run default rake tasks now that rake
has been replaced by rails
. rails
alone gives a list of possible commands rails responds to but doesn't run the specs. rails test
seems logical but it tries to run minitest which we don't use. rails spec
will run Rspec but not teaspoon or rubocop.
Where did this go? And why is something so apparently simple so hard for me to look up myself?
ruby-on-rails rspec rake rakefile
add a comment |
up vote
0
down vote
favorite
Here's a layup for someone...
Back in Rails <= 4 days we'd run our test suite by simply typing $ rake
at the command line, thanks to defaults in Rakefile:
task default: [:rubocop, :spec, :teaspoon]
but in Rails 5 it's not so apparent how to run default rake tasks now that rake
has been replaced by rails
. rails
alone gives a list of possible commands rails responds to but doesn't run the specs. rails test
seems logical but it tries to run minitest which we don't use. rails spec
will run Rspec but not teaspoon or rubocop.
Where did this go? And why is something so apparently simple so hard for me to look up myself?
ruby-on-rails rspec rake rakefile
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Here's a layup for someone...
Back in Rails <= 4 days we'd run our test suite by simply typing $ rake
at the command line, thanks to defaults in Rakefile:
task default: [:rubocop, :spec, :teaspoon]
but in Rails 5 it's not so apparent how to run default rake tasks now that rake
has been replaced by rails
. rails
alone gives a list of possible commands rails responds to but doesn't run the specs. rails test
seems logical but it tries to run minitest which we don't use. rails spec
will run Rspec but not teaspoon or rubocop.
Where did this go? And why is something so apparently simple so hard for me to look up myself?
ruby-on-rails rspec rake rakefile
Here's a layup for someone...
Back in Rails <= 4 days we'd run our test suite by simply typing $ rake
at the command line, thanks to defaults in Rakefile:
task default: [:rubocop, :spec, :teaspoon]
but in Rails 5 it's not so apparent how to run default rake tasks now that rake
has been replaced by rails
. rails
alone gives a list of possible commands rails responds to but doesn't run the specs. rails test
seems logical but it tries to run minitest which we don't use. rails spec
will run Rspec but not teaspoon or rubocop.
Where did this go? And why is something so apparently simple so hard for me to look up myself?
ruby-on-rails rspec rake rakefile
ruby-on-rails rspec rake rakefile
asked Nov 9 at 18:59
Meltemi
20.9k42168256
20.9k42168256
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
rails default
executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.
add a comment |
up vote
0
down vote
Just create a new rake
task that runs the other ones:
lib/tasks/my_extensions.rake
task :my_test do
Rake::Task[:foo].invoke
Rake::Task[:bar].invoke
end
# or the short version:
# task my_test: [:foo, :bar]
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
Run rails my_test
and you will see FOO
and BAR
printed in your console.
If you don't know where to place the file to write the code above, check your /Rakefile
:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
It says to write them inside lib/tasks
and end them with .rake
, you don't need to require them. In your specific question, change my code from :foo
and :bar
to your specific tasks :rubocop :spec :teaspoon
.
However, it looks like you are doing some BDD or TDD cycle. Check out rails Guard, it might help you better. I use it in my project and it works perfectly.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
rails default
executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.
add a comment |
up vote
1
down vote
accepted
rails default
executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
rails default
executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.
rails default
executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.
answered Nov 9 at 20:00
DylanReile
34237
34237
add a comment |
add a comment |
up vote
0
down vote
Just create a new rake
task that runs the other ones:
lib/tasks/my_extensions.rake
task :my_test do
Rake::Task[:foo].invoke
Rake::Task[:bar].invoke
end
# or the short version:
# task my_test: [:foo, :bar]
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
Run rails my_test
and you will see FOO
and BAR
printed in your console.
If you don't know where to place the file to write the code above, check your /Rakefile
:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
It says to write them inside lib/tasks
and end them with .rake
, you don't need to require them. In your specific question, change my code from :foo
and :bar
to your specific tasks :rubocop :spec :teaspoon
.
However, it looks like you are doing some BDD or TDD cycle. Check out rails Guard, it might help you better. I use it in my project and it works perfectly.
add a comment |
up vote
0
down vote
Just create a new rake
task that runs the other ones:
lib/tasks/my_extensions.rake
task :my_test do
Rake::Task[:foo].invoke
Rake::Task[:bar].invoke
end
# or the short version:
# task my_test: [:foo, :bar]
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
Run rails my_test
and you will see FOO
and BAR
printed in your console.
If you don't know where to place the file to write the code above, check your /Rakefile
:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
It says to write them inside lib/tasks
and end them with .rake
, you don't need to require them. In your specific question, change my code from :foo
and :bar
to your specific tasks :rubocop :spec :teaspoon
.
However, it looks like you are doing some BDD or TDD cycle. Check out rails Guard, it might help you better. I use it in my project and it works perfectly.
add a comment |
up vote
0
down vote
up vote
0
down vote
Just create a new rake
task that runs the other ones:
lib/tasks/my_extensions.rake
task :my_test do
Rake::Task[:foo].invoke
Rake::Task[:bar].invoke
end
# or the short version:
# task my_test: [:foo, :bar]
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
Run rails my_test
and you will see FOO
and BAR
printed in your console.
If you don't know where to place the file to write the code above, check your /Rakefile
:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
It says to write them inside lib/tasks
and end them with .rake
, you don't need to require them. In your specific question, change my code from :foo
and :bar
to your specific tasks :rubocop :spec :teaspoon
.
However, it looks like you are doing some BDD or TDD cycle. Check out rails Guard, it might help you better. I use it in my project and it works perfectly.
Just create a new rake
task that runs the other ones:
lib/tasks/my_extensions.rake
task :my_test do
Rake::Task[:foo].invoke
Rake::Task[:bar].invoke
end
# or the short version:
# task my_test: [:foo, :bar]
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
Run rails my_test
and you will see FOO
and BAR
printed in your console.
If you don't know where to place the file to write the code above, check your /Rakefile
:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
It says to write them inside lib/tasks
and end them with .rake
, you don't need to require them. In your specific question, change my code from :foo
and :bar
to your specific tasks :rubocop :spec :teaspoon
.
However, it looks like you are doing some BDD or TDD cycle. Check out rails Guard, it might help you better. I use it in my project and it works perfectly.
answered Nov 9 at 20:04
byrdEmmanuel
662115
662115
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231811%2fhow-to-run-default-rake-tasks-in-rails-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown