require "spec_helper" describe BBC::Cosmos::Config do subject { BBC::Cosmos::Config } let (:expected_cosmos_config) do { :external_dependencies => {}, :secure_configuration => {}, :name => "app_name", :environment => "test", :configuration => { :config_key => "config_value" }, :resources => {} } end let (:expected_config) { expected_cosmos_config[:configuration] } describe ".app" do describe "application config attribute" do it "should be accessible using method notation" do expect(subject.app.config_key).to eq("config_value") end end end describe ".cosmos" do describe "#component_config" do it "returns the cosmos component_config" do expect(subject.cosmos.component_config).to eq(expected_config) end end describe "#config" do it "returns the complete cosmos config" do expect(subject.cosmos.config).to eq(expected_cosmos_config) end end describe "#environment" do it "returns the environment from the cosmos config" do expect(subject.cosmos.environment).to eq('test') end end describe "#stack_name" do it "returns the cosmos stack name" do expect(subject.cosmos.stack_name).to eq("stack_name") end end describe "#component_name" do it "returns the cosmos component name" do expect(subject.cosmos.component_name).to eq("component_name") end end end describe ".aws" do describe "#tags" do it "returns the aws tags" do expect(subject.aws.tags).to eq( { "aws:cloudformation:stack-name" => "stack_name", "Component" => "component_name", "AppName" => "app_name" } ) end end describe "#region" do it "returns the aws region" do expect(subject.aws.region).to eq("eu-west-1") end end describe "#region" do it "returns the aws instance_id" do expect(subject.aws.instance_id).to eq("instance_id") end end end end