spec/buildrdeb/package_spec.rb in buildrdeb-0.0.3 vs spec/buildrdeb/package_spec.rb in buildrdeb-1.0.0

- old
+ new

@@ -40,31 +40,33 @@ More descriptive text. CONTROL Buildr::write "control2", "" Buildr::write "postinst", "" Buildr::write "prerm", "" + Buildr::write "postinst2", <<-POSTINST2 +bash generate_code(#\{MY_CUSTOM_VALUE\}) +POSTINST2 end it "should throw an error if no control file is given" do write_files define("foo", :version => "1.0") do project.package(:deb).postinst = _("postinst") project.package(:deb).prerm = _("prerm") end - lambda { project("foo").package(:deb).invoke }.should raise_error(/no control file was defined when packaging foo as a deb file/) + lambda { project("foo").package(:deb).invoke }.should raise_error(/no control file was defined when packaging as a deb file/) end it "should raise an exception if the control is incorrectly formatted" do write_files define("foo", :version => "1.0") do project.package(:deb).control = _("control2") project.package(:deb).postinst = _("postinst") project.package(:deb).prerm = _("prerm") end lambda { project("foo").package(:deb).invoke }.should raise_error(/dpkg failed with this error:/) - File.exists?("target/foo-1.0.deb").should be_false end it "should give a project the ability to package as deb" do write_files define("foo", :version => "1.0") do @@ -84,12 +86,13 @@ define("foo", :version => "1.0") do project.package(:deb).control = _("control") project.package(:deb).postinst = _("postinst") project.package(:deb).prerm = _("prerm") project.package(:deb).include("blah.class", :path => "lib") - project.package(:deb).include("folder", :as => "otherlib") + project.package(:deb).include("folder", :as => "otherlib/") end + project("foo").package(:deb).invoke lambda { project("foo").package(:deb).invoke }.should_not raise_error File.exists?("target/foo-1.0.deb").should be_true #check the contents of the deb file: entries = %x[ dpkg --contents target/foo-1.0.deb ].split("\n").collect { |string| /.* (.*)/.match(string)[1]} @@ -108,7 +111,38 @@ deb.prerm = _("prerm") end end project("foo").package(:deb, :file => "bar-1.0.deb").invoke File.exists?("bar-1.0.deb").should be_true + end + + it 'should change the version in the control file' do + write_files + define("foo", :version => "2.0") do + project.package(:deb).tap do |deb| + deb.control = _("control") + deb.postinst = _("postinst") + deb.prerm = _("prerm") + end + end + project("foo").package(:deb).invoke + File.exists?( project("foo").package(:deb).to_s).should be_true + File.exists?("target/foo-2.0.deb-contents/DEBIAN/control").should be_true + File.read("target/foo-2.0.deb-contents/DEBIAN/control").should match /^Version: 2.0$/ + end + + it "should evaluate the contents of the file" do + write_files + define("foo", :version => "2.0") do + project.package(:deb).tap do |deb| + deb.control = _("control") + deb.postinst = _("postinst2") + deb.prerm = _("prerm") + end + end + MY_CUSTOM_VALUE = "custom" + project("foo").package(:deb).invoke + File.exists?( project("foo").package(:deb).to_s).should be_true + File.exists?("target/foo-2.0.deb-contents/DEBIAN/postinst").should be_true + File.read("target/foo-2.0.deb-contents/DEBIAN/postinst").should match MY_CUSTOM_VALUE end end \ No newline at end of file