Sha256: 585445b85fe0a1bf4b2083d244582df657954bbb98fa9aa86733c7c43ff52269
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' require 'hobo/paths' require 'hobo/config/file' describe Hobo::Config::File do before do Hobo.project_path = nil FakeFS.activate! end after do FakeFS::FileSystem.clear FakeFS.deactivate! end def fake_config { :string => "string", :integer => 0, :boolean => true, :hash => { :test => true }, :array => [ 1 ] } end describe "save" do it "should save config hash to specified file" do Hobo::Config::File.save "test.yaml", fake_config File.read("test.yaml").should match /string: string/ end it "should automatically unwrap deepstruct" do Hobo::Config::File.save "test.yaml", DeepStruct.wrap(fake_config) File.read("test.yaml").should match /string: string/ end end describe "load" do it "should wrap loaded config with DeepStruct::HashWrapper" do Hobo::Config::File.save "test.yaml", fake_config Hobo::Config::File.load("test.yaml").should be_an_instance_of DeepStruct::HashWrapper end it "should load config hash from file" do Hobo::Config::File.save "test.yaml", fake_config fake_config().should eq Hobo::Config::File.load("test.yaml").unwrap end it "should return empty config if file does not exist" do Hobo::Config::File.load("test.yaml").unwrap.should eq({}) end it "should raise error if file can't be parsed" do File.write("test.yaml", "##Invalid yaml file") expect { Hobo::Config::File.load("test.yaml") }.to raise_error(RuntimeError, "Invalid hobo configuration (test.yaml)") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hobo-inviqa-0.0.7 | spec/hobo/config/file_spec.rb |
hobo-inviqa-0.0.6 | spec/hobo/config/file_spec.rb |