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?










share|improve this question

























    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?










    share|improve this question























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 18:59









      Meltemi

      20.9k42168256




      20.9k42168256






















          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.






          share|improve this answer



























            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.






            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              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

























              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.






              share|improve this answer
























                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.






                share|improve this answer






















                  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.






                  share|improve this answer












                  rails default
                  executes those tasks for me on Rails 5.2.1, though I couldn't find it documented anywhere.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 9 at 20:00









                  DylanReile

                  34237




                  34237






















                      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.






                      share|improve this answer
























                        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.






                        share|improve this answer






















                          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.






                          share|improve this answer












                          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.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 9 at 20:04









                          byrdEmmanuel

                          662115




                          662115



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                              Syphilis

                              Darth Vader #20