Reputation: 15491
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
Upvotes: 1
Views: 565
Reputation: 1793
I would suggest using this gem:
https://github.com/oshuma/app_config
Given this YAML file:
---
admin_email: '[email protected]'
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 # => '[email protected]'
AppConfig.api_name # => 'Supr Webz 2.0'
AppConfig.api_key # => 'SUPERAWESOMESERVICE'
This could easily be added to your spec_helper
Upvotes: 1