organize rspec2 tests into unit(fast) and integration(slow) categories_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > organize rspec2 tests into unit(fast) and integration(slow) categories

organize rspec2 tests into unit(fast) and integration(slow) categories

 2013/1/25 11:09:47  grantbb  程序员俱乐部  我要评论(0)
  • 摘要:IwishIcanusetheseundercommandstorunthetests.rakespec#runalltestsrakespec:integration#runallintegrationtestsrakespec:unit#runallunittestsSothat'swhatIdoinmyRakefile:defrun_test(scope)RSpec::Core::RakeTask.new(scope)do|t|t.rspec_opts=%w{--colour-
  • 标签:

I wish I can use these under commands to run the tests.

?

rake spec                    # run all tests
rake spec:integration  # run all integration tests
rake spec:unit            # run all unit tests

?

So that's what I do in my Rakefile:

?

def run_test(scope)
  RSpec::Core::RakeTask.new(scope) do |t|
    t.rspec_opts = %w{--colour --format progress}
    t.pattern = "spec/#{scope.to_s}/**/*_spec.rb"
  end
end

namespace :spec do
  ENV['RACK_ENV'] = 'test'

  desc "run all unit tests"
  run_test(:unit)

  desc "run all integration tests"
  run_test(:integration)

end

desc "run all tests"
task :spec => ["spec:unit", "spec:integration"]
?
  • 相关文章
发表评论
用户名: 匿名