From a7468be6e48f68797eb829f166f8564d289e17db Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Thu, 8 Mar 2012 00:03:04 -0800 Subject: [PATCH] - try using rspec+insist --- Gemfile | 6 --- Gemfile.lock | 28 ++++++----- fpm.gemspec | 3 ++ spec/fpm/package/rpm_spec.rb | 38 +++++++++++++++ spec/fpm/package_spec.rb | 29 +++++++++++ test/fpm/package/dir.rb | 93 ------------------------------------ 6 files changed, 86 insertions(+), 111 deletions(-) create mode 100644 spec/fpm/package/rpm_spec.rb delete mode 100644 test/fpm/package/dir.rb diff --git a/Gemfile b/Gemfile index ffea1514a9..a1b93f3ed1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,3 @@ source :rubygems gemspec - -group :development do - gem "guard" - gem "guard-minitest" - gem "guard-shell" -end diff --git a/Gemfile.lock b/Gemfile.lock index 369f7e7b4e..c343ed15cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,6 +2,7 @@ PATH remote: . specs: fpm (0.4.0) + arr-pm backports (= 2.3.0) cabin (~> 0.4.2) json @@ -9,31 +10,34 @@ PATH GEM remote: http://rubygems.org/ specs: + arr-pm (0.0.2) + cabin (> 0) backports (2.3.0) cabin (0.4.2) json + diff-lcs (1.1.3) fattr (2.2.1) - ffi (1.0.11) - guard (1.0.0) - ffi (>= 0.5.0) - thor (~> 0.14.6) - guard-minitest (0.3.0) - guard (>= 0.2.2) - guard-shell (0.3.0) - guard (>= 0.2.0) + insist (0.0.1) + cabin (> 0) json (1.6.5) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) rush (0.6.7) session session (3.1.0) fattr - thor (0.14.6) PLATFORMS ruby DEPENDENCIES fpm! - guard - guard-minitest - guard-shell + insist + rspec rush diff --git a/fpm.gemspec b/fpm.gemspec index eb0c228b27..bc774511b5 100644 --- a/fpm.gemspec +++ b/fpm.gemspec @@ -35,6 +35,9 @@ Gem::Specification.new do |spec| # http://rush.heroku.com/rdoc/ spec.add_development_dependency("rush") # license: MIT + spec.add_development_dependency("rspec") # license: ??? + spec.add_development_dependency("insist") # license: ??? + spec.files = files spec.require_paths << "lib" spec.bindir = "bin" diff --git a/spec/fpm/package/rpm_spec.rb b/spec/fpm/package/rpm_spec.rb new file mode 100644 index 0000000000..af090b57e8 --- /dev/null +++ b/spec/fpm/package/rpm_spec.rb @@ -0,0 +1,38 @@ +require "spec_setup" +require "fpm" # local +require "fpm/package/rpm" # local +require "fpm/package/dir" # local +require "rpm" # gem arr-pm + +describe FPM::Package::RPM do + subject { FPM::Package::RPM.new } + + before :each do + @target = Tempfile.new + end # before + + after :each do + subject.cleanup + @target.close + end # after + + describe "#output" do + context "basics" do + before :each do + + end + + it "should output a package with the correct name" do + subject.output(@target.path) + rpm = RPM::File.new(@target.path) + # TODO(sissel): verify rpm name vs subject.name + + end + + it "should output a package with the correct version" + it "should output a package with the correct iteration" + it "should output a package with the correct epoch" + it "should output a package with the correct dependencies" + end + +end # describe FPM::Package::Dir diff --git a/spec/fpm/package_spec.rb b/spec/fpm/package_spec.rb index 30526819d0..056c1d5736 100644 --- a/spec/fpm/package_spec.rb +++ b/spec/fpm/package_spec.rb @@ -21,4 +21,33 @@ insist { subject.name } == name end end + + describe "#version" do + it "should default to '1.0'" do + insist { subject.version } == "1.0" + end + + it "should allow setting the package name" do + version = "hello" + subject.version = version + insist { subject.version } == version + end + end + + describe "#architecture" + describe "#attributes" + describe "#category" + describe "#config_files" + describe "#conflicts" + describe "#dependencies" + describe "#description" + describe "#epoch" + describe "#iteration" + describe "#license" + describe "#maintainer" + describe "#provides" + describe "#replaces" + describe "#scripts" + describe "#url" + describe "#vendor" end # describe FPM::Package diff --git a/test/fpm/package/dir.rb b/test/fpm/package/dir.rb deleted file mode 100644 index 1bb0306761..0000000000 --- a/test/fpm/package/dir.rb +++ /dev/null @@ -1,93 +0,0 @@ -require "rubygems" -require File.join(File.dirname(File.expand_path(__FILE__)), "..", "..", "testing") -$: << File.join(File.dirname(File.expand_path(__FILE__)), "..", "..", "..", "lib") -require "minitest/autorun" -require "tmpdir" -require "fileutils" -require "fpm/package/dir" -require "rush" # for simple file stuff - -if $DEBUG or ENV["DEBUG"] - Cabin::Channel.get.level = :debug - Cabin::Channel.get.subscribe(STDOUT) -end - -describe FPM::Package::Dir do - before do - @source = FPM::Package::Dir.new - @rush = Rush::Box.new("localhost") - @tmpdir = @rush[::Dir.mktmpdir("package-test-tmpdir")] - @output = @rush[::Dir.mktmpdir("package-test-output")] - end # before - - after do - @source.cleanup - FileUtils.rm_r(@tmpdir.full_path) - FileUtils.rm_r(@output.full_path) - end # after - - test "adding a single file" do - file = @tmpdir["hello"] - file.write "Hello world" - @source.input(@tmpdir.full_path) - @source.output(@output.full_path) - - assert_equal(@output[File.join(".", file.full_path)].contents, - file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output") - end - - test "single file in a directory" do - dir = @tmpdir.create_dir("a/b/c") - file = dir.create_file("hello") - file.write "Hello world" - @source.input(@tmpdir.full_path) - - @source.output(@output.full_path) - assert_equal(@output[File.join(".", file.full_path)].contents, - file.contents, "The file #{@tmpdir["a/b/c/hello"].full_path} should appear in the output") - end - - test "multiple files" do - dir = @tmpdir.create_dir("a/b/c") - files = rand(50).times.collect do |i| - dir.create_file("hello-#{i}") - end - files.each { |f| f.write(rand(1000)) } - - @source.input(@tmpdir.full_path) - @source.output(@output.full_path) - - files.each do |file| - assert_equal(@output[File.join(".", file.full_path)].contents, - file.contents, "The file #{file.full_path} should appear in the output") - end - end - - test "single file with prefix" do - prefix = @source.attributes[:prefix] = "/usr/local" - file = @tmpdir["hello"] - file.write "Hello world" - @source.input(@tmpdir.full_path) - @source.output(@output.full_path) - - expected_path = File.join(".", file.full_path) - - assert_equal(@output[File.join(prefix, expected_path)].contents, - file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output") - end - - test "single file with prefix and chdir" do - prefix = @source.attributes[:prefix] = "/usr/local" - chdir = @source.attributes[:chdir] = @tmpdir.full_path - file = @tmpdir["hello"] - file.write "Hello world" - @source.input(".") # since we chdir, copy the entire root - @source.output(@output.full_path) - - # path relative to the @output directory. - expected_path = File.join(".", prefix, file.name) - assert_equal(@output[expected_path].contents, - file.contents, "The file #{@tmpdir["hello"].full_path} should appear in the output") - end - -end # describe FPM::Package::Dir