spec/unit/loader_spec.rb in a9n-0.4.2 vs spec/unit/loader_spec.rb in a9n-0.4.3

- old
+ new

@@ -11,19 +11,19 @@ it { expect(subject.local_file).to eq(file_path) } it { expect(subject.example_file).to eq("#{file_path}.example") } end describe "#load" do - let(:example_config) { + let(:example_config) do { app_url: "http://127.0.0.1:3000", api_key: "example1234" } - } - let(:local_config) { + end + + let(:local_config) do { app_host: "127.0.0.1:3000", api_key: "local1234" } - } - let(:env){ - "tropical" - } + end + + let(:env) { "tropical" } let(:config) { subject.get } context "when no configuration file exists" do before do expect(described_class).to receive(:load_yml).with(subject.example_file, env).and_return(nil) @@ -120,13 +120,19 @@ expect(subject.keys).to_not be_empty end end before do - ENV["DWARF"] = "erbized dwarf" + ENV["ERB_DWARF"] = "erbized dwarf" + ENV["DWARF_PASSWORD"] = "dwarf123" end + after do + ENV["ERB_DWARF"] = nil + ENV["DWARF_PASSWORD"] = nil + end + context "when file has erb extension" do let(:file_path) { File.join(root, "config/a9n/cloud.yml.erb") } it_behaves_like "non-empty config file" end @@ -147,9 +153,14 @@ expect(subject[:hash_dwarf].keys.first).to be_kind_of(Symbol) end it "parses erb" do expect(subject[:erb_dwarf]).to eq("erbized dwarf") + end + + it "gets valus from ENV" do + p subject + expect(subject[:dwarf_password]).to eq("dwarf123") end end context "having no env and only defaults data" do let(:file_path) { File.join(root, "config/configuration.yml") }