Sha256: 15177623fc0cc7b389fc14b4390ce3e650c65b76238cdad85b1dad6550f480c4
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' class UserPage include DataMagic end describe DataMagic do context "when configuring the yml directory" do before(:each) do DataMagic.yml_directory = nil end it "should default to a directory named config" do DataMagic.yml_directory.should == 'config/data' end it "should store a yml directory" do DataMagic.yml_directory = 'test_dir' DataMagic.yml_directory.should == 'test_dir' end end context "when reading yml files" do it "should read files from the config directory" do DataMagic.yml_directory = 'test' YAML.should_receive(:load_file).with("test/fname").and_return({}) DataMagic.load("fname") end it "should default to reading a file named default.yml" do DataMagic.yml_directory = 'config/data' DataMagic.yml = nil data = UserPage.new.data_for :dm expect(data.keys).to include('value1') end it "should use the value of DATA_MAGIC_FILE if it exists" do DataMagic.yml_directory = 'config/data' DataMagic.yml = nil ENV['DATA_MAGIC_FILE'] = 'user.yml' data = UserPage.new.data_for "valid" expect(data.keys.sort).to eq(['job','name']) ENV['DATA_MAGIC_FILE'] = nil end end context "namespaced keys" do it "loads correct file and retrieves data" do DataMagic.yml_directory = 'config/data' data = UserPage.new.data_for "user/valid" expect(data.keys.sort).to eq(['job','name']) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
data_magic-0.18 | spec/lib/data_magic_spec.rb |