Sha256: 8d38c3d92393c4e657ccd62db37ee0c1af9f20ba3ba175f60491cf6a8dcb6b92
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
require 'helper' describe 'DSL proxies' do let(:target){ OpenStruct.new } let(:dsl){ Mutaconf::DSL.new options } let(:options){ { proxy: { target => true } } } let(:block){ lambda{} } it "should proxy method calls with instance evaluation" do target.should_receive(:a).with('b') target.should_receive(:c=).with('d') target.should_receive(:e).with('f', &block) result = dsl.configure do a 'b' self.c = 'd' e 'f', &block end result.should be(dsl) end it "should proxy method calls with a configuration object" do target.should_receive(:a=).with('b') target.should_receive(:c=).with('d') result = dsl.configure do |config| config.a = 'b' config.c = 'd' end result.should be(dsl) end context "with restricted keys" do let(:options){ { proxy: { target => [ :a ] } } } it "should raise a key error for a unknown key with instance evaluation" do lambda{ dsl.configure{ b 'c' } }.should raise_error(Mutaconf::KeyError, /'b'/) end it "should raise a key error for an unknown key with a configuration object" do lambda{ dsl.configure{ |config| config.b = 'c' } }.should raise_error(Mutaconf::KeyError, /'b'/) end end context "with restricted keys in lenient mode" do let(:options){ { proxy: { target => [ :a, :e ] }, lenient: true } } it "should configure restricted properties with instance evaluation" do target.should_receive(:a).with('b', &block) target.should_receive(:e).with('f') result = dsl.configure do a 'b', &block c 'd' e 'f' g 'h' end result.should be(dsl) end it "should configure restricted properties with a configuration object" do target.should_receive(:a=).with('b') target.should_receive(:e=).with('f') result = dsl.configure do |config| config.a = 'b' config.c = 'd' config.e = 'f' config.g = 'h' end result.should be(dsl) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mutaconf-0.1.1 | spec/proxy_spec.rb |