如何使用RSpec :: Core :: RakeTask创建RSpec Rake任务?

eme*_*ery 5 ruby rake rspec

如何使用RSpec :: Core :: RakeTask初始化RSpec Rake任务?

require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new do |t|
  # what do I put in here?
end

http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initialize-instance_method中记录的Initialize函数 没有很好的记录; 它只是说:

 - (RakeTask) initialize(*args, &task_block)

A new instance of RakeTask

我应该为*args和&task_block添加什么?

我跟随已经开始使用RSpec与Rake结合为PHP项目构建一些ruby自动化的人的脚步.我习惯使用没有Rake的RSpec,所以我不熟悉语法.

谢谢,-Kevin

Igo*_*orM 6

这是我的Rakefile的一个例子:

require 'rspec/core/rake_task'

task :default => [:spec]

desc "Run the specs."
RSpec::Core::RakeTask.new do |t|
  t.pattern = "spec.rb"
end

desc "Run the specs whenever a relevant file changes."
task :watch do
  system "watchr watch.rb"
end
Run Code Online (Sandbox Code Playgroud)

这允许从Rake运行spec.rb文件中定义的规范

  • 我用`t.pattern ="spec/**/*_ spec.rb"`.谢谢. (3认同)