spec/config_spec.rb in anyway_config-0.1.0 vs spec/config_spec.rb in anyway_config-0.2.0

- old
+ new

@@ -27,11 +27,11 @@ it "should load config from YAML" do expect(conf.host).to eq "test.host" end - unless Rails.application.try(:secrets).nil? + if Rails.application.respond_to?(:secrets) it "should load config from secrets" do expect(conf.user[:name]).to eq "test" expect(conf.user[:password]).to eq "test" end else @@ -92,8 +92,23 @@ ENV['ANYWAY_API__KEY'] = 'test1' ENV['ANYWAY_TEST'] = 'test' Anyway.env.reload expect(test_conf.api[:key]).to eq "test1" expect(test_conf.test).to eq "test" + end + end + + describe "config for name" do + after(:each) { Anyway.env.clear } + it "should load data by config name" do + ENV['MYAPP_TEST'] = '1' + ENV['MYAPP_NAME'] = 'my_app' + Anyway.env.reload + data = Anyway::Config.for(:my_app) + expect(data[:test]).to eq '1' + expect(data[:name]).to eq 'my_app' + if Rails.application.respond_to?(:secrets) + expect(data[:secret]).to eq 'my_secret' + end end end end \ No newline at end of file