Sha256: 1e5419b9ca3e0713fe0ba024a8ea01513843ff8be86af89dad5164ef7b83e90b
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 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 expect(DataMagic.yml_directory).to eql 'config/data' end it "should store a yml directory" do DataMagic.yml_directory = 'test_dir' expect(DataMagic.yml_directory).to eql 'test_dir' end it "should accept and use locale" do expect(Faker::Config).to receive(:locale=).with('blah') DataMagic.locale = 'blah' end end context "when reading yml files" do it "should read files from the config directory" do DataMagic.yml_directory = 'test' expect(File).to receive(:read).with("test/fname").and_return('test') 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
data_magic-0.22 | spec/lib/data_magic_spec.rb |
data_magic-0.21 | spec/lib/data_magic_spec.rb |