加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 03:36:45 所属栏目:百科 来源:网络整理
导读:如何使用RSpec :: Core :: RakeTask初始化RSpec Rake任务? require 'rspec/core/rake_task'RSpec::Core::RakeTask.new do |t| # what do I put in here?end Initialize函数记录在 http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initial
如何使用RSpec :: Core :: RakeTask初始化RSpec Rake任务?

require 'rspec/core/rake_task'

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

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

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

A new instance of RakeTask

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

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

谢谢,
-Kevin

解决方法

这是我的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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读