1

I have this config/initializer.rb which lets me load a yaml /config/application.yaml and do something like APP_CONFIG["myvar"] how could I enable this for my SPECS also?

My goal is to do something like:

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
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • Is this a gem you're using, or something you wrote yourself? – Farley Knight Sep 30 '13 at 21:25
  • @farleyknight something like this :http://fredwu.me/post/632640092/rails-use-app-config-for-your-application-specific – Rubytastic Sep 30 '13 at 21:26
  • That blog post is from 2010, and the project it links to is no longer maintained. I'd look for a way to migrate to the new project that is linked to on the github page. – Farley Knight Sep 30 '13 at 21:28
  • From the [Github page](https://github.com/cjbottaro/app_config): This project is no longer supported or maintained. It has been superceded by ConfigSpartan: github.com/cjbottaro/config_spartan – Farley Knight Sep 30 '13 at 21:29
  • @farleyknight just google for app_config ruby on rails and pick a more recent blog post its documented several times good luck – Rubytastic Sep 30 '13 at 21:49

1 Answers1

1

I would suggest using this gem:

https://github.com/oshuma/app_config

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'

This could easily be added to your spec_helper

Farley Knight
  • 1,795
  • 1
  • 13
  • 17
  • actually i have this already implemented, but an if statement fails in the spec itself. I kinda have a global and production, development section that is getting read more advanced than this gem i rephrase question its to unclear now – Rubytastic Sep 30 '13 at 23:48
  • Repost your question if it's completely different from the original. – Farley Knight Oct 01 '13 at 00:25