spec/mvcli/provisioning_spec.rb in mvcli-0.0.5 vs spec/mvcli/provisioning_spec.rb in mvcli-0.0.6

- old
+ new

@@ -6,22 +6,28 @@ describe "Scope" do Given(:provisioner) {{}} Given(:mod) {Module.new {include MVCLI::Provisioning}} Given(:cls) {m = mod; Class.new {include m}} Given(:obj) {cls.new} - Given(:container) {MVCLI::Provisioning::Scope.new provisioner} + Given(:command) {mock(:Command)} + Given(:scope) {MVCLI::Provisioning::Scope.new command, provisioner} + context "when the command is required" do + Given {mod.requires :command} + When(:result) {scope.evaluate {obj.command}} + Then {result == command} + end context "with a requirement is specified on the module" do Given {mod.requires :foo} context "when accessing it but it is not present" do - When(:result) {container.evaluate {obj.foo}} + When(:result) {scope.evaluate {obj.foo}} Then {result.should have_failed MVCLI::Provisioning::UnsatisfiedRequirement, /foo/} end context "and there is a scope which satisfies the requirement" do Given(:foo) {Object.new} Given {provisioner[:foo] = foo} - context "when a dependency is accessed in the context of the container" do - When(:result) {container.evaluate {obj.foo}} + context "when a dependency is accessed in the context of the scope" do + When(:result) {scope.evaluate {obj.foo}} Then {result == foo} end end context "accessing requirements with no scope" do When(:result) {obj.foo}