你如何使用黄瓜与宙斯?

时间:2017-01-30 22:34:23

标签: ruby cucumber zeus

当我启动宙斯时,它不提供zeus cucumber作为可能的命令之一。其他人似乎默认得到这个;至少我看过一些Zeus写作,显示来自zeus start的输出,包括zeus cucumber,并且他们没有说任何关于特殊或需要额外配置的内容。

我甚至不知道从哪里开始排除故障;我用Google搜索并搜索了#34;用黄瓜和宙斯一起使用。"我没有进行设置讨论。我得到的唯一结果来自那些似乎理所当然地认为它应该在那里的人,并且正在研究它无法正常运作的问题。

1 个答案:

答案 0 :(得分:1)

您应该使用Zeus的this custom plan文件。将其保存为应用程序根目录中的custom_plan.rb

require 'zeus/rails'                   

# 1. Add the cucumber methods (below) to your custom plan (or take this file if
# you don't have an existing custom_plan).
#
# 2. Add the following line to the test_environment section of your zeus.json:
#
#   "cucumber_environment": {"cucumber": []}

class CucumberPlan < Zeus::Rails         
  def cucumber_environment
    ::Rails.env = ENV['RAILS_ENV'] = 'test'
    require 'cucumber/rspec/disable_option_parser'
    require 'cucumber/cli/main'
    @cucumber_runtime = Cucumber::Runtime.new
  end

  def cucumber(argv=ARGV)
    cucumber_main = Cucumber::Cli::Main.new(argv.dup)
    had_failures = cucumber_main.execute!(@cucumber_runtime)
    exit_code = had_failures ? 1 : 0
    exit exit_code
  end
end

Zeus.plan = CucumberPlan.new