pivotallabs.com
17 Feb '12, 7am
@kei_s 参考になるかわかりませんが、最近Pivotal Labsブログにこんな記事がありました。 / Test your Rake tasks!
There are several reasons why you should test your Rake tasks: Rake tasks are code and as such deserve testing. When untested Rake tasks have a tendency to become overly long and convoluted. Tests will help keep them in bay. As Rake tasks typically depend on your models, you (should) loose confidence in them if you don't have tests and are attempting refactorings. A problematic Rake task test Here is a Rake file... File: lib/tasks/bar_problematic.rake namespace :foo do desc "bake some bars" task bake_a_problematic_bar: :environment do puts '*' * 60 puts ' Step back: baking in action!' puts '*' * 60 puts Bar.new.bake puts '*' * 60 puts ' All done. Thank you for your patience.' puts '*' * 60 end end ...and its too simplistic spec: File: spec/tasks/bar_rake_problematic_spec.rb require 'spec_helper' require 'rake' describe 'foo namespace rake task' do describe 'foo:bake_a_prob...
Full article:
http://pivotallabs.com/users/shagemann/blog/articles/1967...