【问题标题】:How do you use cucumber with zeus?你怎么用黄瓜和宙斯?
【发布时间】:2017-02-07 05:42:17
【问题描述】:

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

我什至不知道从哪里开始解决这个问题;我用谷歌搜索并在这里搜索“用黄瓜和宙斯一起使用”。我没有得到任何设置讨论。我得到的唯一结果来自那些似乎理所当然地认为它应该在那里的人,并且正在调查它无法正常运行的问题。

【问题讨论】:

    标签: ruby cucumber zeus


    【解决方案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
    

    【讨论】:

    • 您将require 'zeus/rails' 留在了代码围栏之外。但除此之外,太好了 - 非常感谢!
    猜你喜欢
    • 2018-05-04
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    相关资源
    最近更新 更多