Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何使用if语句在规范内执行条件检查?_Ruby On Rails_Rspec_Specs - Fatal编程技术网

Ruby on rails 如何使用if语句在规范内执行条件检查?

Ruby on rails 如何使用if语句在规范内执行条件检查?,ruby-on-rails,rspec,specs,Ruby On Rails,Rspec,Specs,我有一个config/initializer.rb,它允许我加载一个yaml/config/application.yaml并执行类似于APP_config[“myvar”]的操作,我如何也为我的规范启用它 我的目标是做如下事情: require "spec_helper" describe BetaController do describe "routing" do if APP_CONFIG["viral"] and APP_CONFIG["beta"] it

我有一个config/initializer.rb,它允许我加载一个yaml/config/application.yaml并执行类似于APP_config[“myvar”]的操作,我如何也为我的规范启用它

我的目标是做如下事情:

require "spec_helper"

describe BetaController do
  describe "routing" do

    if APP_CONFIG["viral"] and APP_CONFIG["beta"]

      it "routes to #index do" do
        get("/").should route_to("home#index")
      end

    end

  end
end

我建议使用这个宝石:


这可以很容易地添加到您的
spec\u助手中

我建议您使用此gem:


这可以很容易地添加到您的
spec\u helper

这是您正在使用的宝石,还是您自己编写的东西?@farleyknight类似这样的内容:该博客文章来自2010年,它链接到的项目不再维护。我想寻找一种迁移到github页面上链接到的新项目的方法。来自:此项目不再受支持或维护。它已被ConfigSpartan取代:github.com/cjbottaro/config_spartan@farleyknight只需在谷歌上搜索app_config ruby on rails,然后选择一篇最近的博客文章,它记录了好几次好运气这是你正在使用的宝石,还是你自己写的东西?@farleyknight类似这样的东西:那篇博客文章是从2010年开始的,并且它链接到的项目不再被维护。我想寻找一种迁移到github页面上链接到的新项目的方法。来自:此项目不再受支持或维护。它已被ConfigSpartan取代:github.com/cjbottaro/config_spartan@farleyknight只需在谷歌上搜索app_config ruby on rails,并选择一篇最近的博客文章,它记录了好几次。实际上,我已经实现了这一点,但是规范本身的if语句失败了。我有一个全球和生产、开发部分,比这个gem读得更高级。我将问题改为现在不清楚。如果它与原来的完全不同,请重新提出您的问题。实际上我已经实现了这个部分,但是规范本身的if语句失败了。我有一个全球性的,生产,开发的部分,它比这个gem读得更高级,我把它的问题改成现在不清楚,如果它与原来的完全不同,请回复你的问题。
Given this YAML file:

---
admin_email: 'admin@example.com'
api_name:    'Supr Webz 2.0'
api_key:     'SUPERAWESOMESERVICE'
Use it like so:

AppConfig.setup!(yaml: '/path/to/app_config.yml')

# Later on...
AppConfig.admin_email  # => 'admin@example.com'
AppConfig.api_name     # => 'Supr Webz 2.0'
AppConfig.api_key      # => 'SUPERAWESOMESERVICE'