Sha256: 725ca0a43fc3ebf11a3048295b22a5abf266be577fd20cdeceb7e76ddc7a8ec6
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require "spec_helper" module Confset::Sources describe HashSource do it "should take a hash as initializer" do source = HashSource.new(foo: 5) expect(source.hash).to eq(foo: 5) end context "basic hash" do let(:source) do HashSource.new( { "size" => 2, "section" => { "size" => 3, "servers" => [ { "name" => "yahoo.com" }, { "name" => "amazon.com" } ] } } ) end it "should properly read the settings" do results = source.load expect(results["size"]).to eq(2) end it "should properly read nested settings" do results = source.load expect(results["section"]["size"]).to eq(3) expect(results["section"]["servers"]).to be_instance_of(Array) expect(results["section"]["servers"].size).to eq(2) end end context "parameter is not a hash" do let(:source) do HashSource.new "hello world" end it "should return an empty hash" do results = source.load expect(results).to eq({}) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems