spec/unit/loader_spec.rb in a9n-0.4.0 vs spec/unit/loader_spec.rb in a9n-0.4.1

- old
+ new

@@ -28,10 +28,11 @@ before do expect(described_class).to receive(:load_yml).with(subject.example_file, env).and_return(nil) expect(described_class).to receive(:load_yml).with(subject.local_file, env).and_return(nil) expect(subject).to receive(:verify!).never end + it "raises expection" do expect { subject.load }.to raise_error(A9n::MissingConfigurationData) end @@ -46,28 +47,29 @@ end it { expect(config.app_url).to eq("http://127.0.0.1:3000") } it { expect(config.api_key).to eq("example1234") } - it { + it do expect { config.app_host }.to raise_error(A9n::NoSuchConfigurationVariable) - } + end end context "when only local configuration file exists" do before do expect(described_class).to receive(:load_yml).with(subject.example_file, env).and_return(nil) expect(described_class).to receive(:load_yml).with(subject.local_file, env).and_return(local_config) expect(described_class).to receive(:verify!).never subject.load end + it { expect(config.app_host).to eq("127.0.0.1:3000") } it { expect(config.api_key).to eq("local1234") } - it { + it do expect { config.app_url }.to raise_error(A9n::NoSuchConfigurationVariable) - } + end end context "when both local and base configuration file exists without defaults" do context "with same data" do before do @@ -77,13 +79,13 @@ end it { expect(config.app_url).to eq("http://127.0.0.1:3000") } it { expect(config.api_key).to eq("example1234") } - it { + it do expect { config.app_host }.to raise_error(A9n::NoSuchConfigurationVariable) - } + end end context "with different data" do before do expect(described_class).to receive(:load_yml).with(subject.example_file, env).and_return(example_config) @@ -93,11 +95,11 @@ let(:missing_variables_names) { example_config.keys - local_config.keys } it "raises expection with missing variables names" do expect { subject.load - }.to raise_error(A9n::MissingConfigurationVariables, /#{missing_variables_names.join(', ')}/) + }.to raise_error(A9n::MissingConfigurationVariables, /#{missing_variables_names.join(", ")}/) end end end end @@ -117,14 +119,14 @@ expect(subject).to be_kind_of(Hash) expect(subject.keys).to_not be_empty end end - before { + before do ENV["DWARF"] = "erbized dwarf" - } + end - context 'when file has erb extension' do + 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