欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

organize rspec2 tests into 'unit' (fast) and 'integration' (slow) categories 博客分类: Ruby rubyrspecrake 

程序员文章站 2024-02-22 19:18:28
...

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"]
 
相关标签: ruby rspec rake