Permalink
Browse files

- try using rspec+insist

  • Loading branch information...
1 parent 67e730d commit a7468be6e48f68797eb829f166f8564d289e17db @jordansissel committed Mar 8, 2012
Showing with 86 additions and 111 deletions.
  1. +0 −6 Gemfile
  2. +16 −12 Gemfile.lock
  3. +3 −0 fpm.gemspec
  4. +38 −0 spec/fpm/package/rpm_spec.rb
  5. +29 −0 spec/fpm/package_spec.rb
  6. +0 −93 test/fpm/package/dir.rb
View
@@ -1,9 +1,3 @@
source :rubygems
gemspec
-
-group :development do
- gem "guard"
- gem "guard-minitest"
- gem "guard-shell"
-end
View
@@ -2,38 +2,42 @@ PATH
remote: .
specs:
fpm (0.4.0)
+ arr-pm
backports (= 2.3.0)
cabin (~> 0.4.2)
json
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
View
@@ -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"
@@ -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
@@ -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
@@ -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

0 comments on commit a7468be

Please sign in to comment.