spec/configurable.rb in mattock-0.4.1 vs spec/configurable.rb in mattock-0.5.0

- old
+ new

@@ -4,15 +4,20 @@ class TestSuperStruct include Mattock::Configurable setting(:three, 3) required_field(:four) + required_field(:override) end class TestStruct < TestSuperStruct settings(:one => 1, :two => nested(:a => "a"){ required_field(:b)} ) nil_field(:five) + + def override + 17 + end end subject do TestStruct.new.setup_defaults end @@ -47,12 +52,17 @@ subject.four = 4 subject.two.b = "b" expect do subject.check_required end.to_not raise_error + subject.override.should == 17 end + it "should inspect cleanly" do + subject.inspect.should be_a(String) + end + describe "with DirectoryStructure" do class DirectoryThing include Mattock::Configurable include DirectoryStructure @@ -64,10 +74,14 @@ path(:private_key_file, "pk.pem"), path(:certificate_file, "cert.pem") ) ) ) + + dir(:next_to_me, "rainbow", dir(:in_there, "a_place", path(:nearby, "a.file"))) + + path(:loose_path, "here") end def subject DirectoryThing.new.tap do |thing| thing.setup_defaults @@ -78,10 +92,14 @@ expect do subject.check_required end.to raise_error /Required field/ end + it "should inspect cleanly" do + subject.inspect.should be_a(String) + end + describe "with root path configured, but missing a relative path" do def subject DirectoryThing.new.tap do |thing| thing.setup_defaults thing.ephemeral_mountpoint.absolute_path = "/tmp" @@ -110,10 +128,13 @@ expect do subject.check_required end.not_to raise_error end + its("nearby.absolute_path"){ should =~ %r"rainbow/a_place/a.file$"} + its("nearby.absolute_path"){ should =~ %r"^#{subject.absolute_path}"} + its("certificate_file.absolute_path"){ should == "/tmp/bundle_workdir/aws-creds/cert.pem" } its("bundle_manifest.absolute_path"){ should == "/tmp/bundle_workdir/image.manifest.xml" } its("credentials_dir.absolute_path"){ should == "/tmp/bundle_workdir/aws-creds" } end end @@ -182,10 +203,10 @@ let :right do RightStruct.new.setup_defaults end it "should not copy no_copy" do - left.copy_settings.to(right) + left.copy_settings_to(right) right.unset?(right.normal).should be_false right.normal.should == 1 right.unset?(right.no_copy).should be_true right.unset?(right.no_proxy).should be_false right.no_proxy.should == 3