title: How to design a rake task that calls multiple class methods?
body: <p>I have a rake task called <code>pull_orders</code> which calls methods of a <code>RemoteDbConnector</code> class to do things like establish a connection to an external db, generate raw SQL queries, execute queries and store records in the local db.</p>
  
  <p>While trying to test it, I stumbled upon <a href="https://stackoverflow.com/a/33087154/3284936">this answer</a> which got me thinking whether my design is flawed. </p>
  
  <p>Should rake tasks really be one liners? If so, where should I put all these method calls, given that they need to be called in a particular sequence? </p>
  
  <p>My task looks like this:</p>
  
  <pre><code>namespace :db do
    desc 'finds and populates data from remote db'
    task pull_orders: :environment do
      ...
      columns = ...
      table = ...
      options = ...
      column_mappings = ...
      RemoteDbConnector.generate_query(...)
      RemoteDbConnector.execute_query(...)
      RemoteDbConnector.map_column_names(...)
      Order.create(...) #creates records based on hash generated by RemoteDbConnector
      ...
  
    end
  end
  </code></pre>