Permalink
Browse files

Conversion from rspec to minitest.

Add in full api test on authenticated repository
  • Loading branch information...
1 parent e2bc65a commit 22ef2289a628754c27e05b68720177c3a02e0d29 @copiousfreetime committed Sep 14, 2013
Showing with 846 additions and 923 deletions.
  1. +1 −1 examples/auth_repo.ru
  2. +1 −1 examples/gemcutter_repo.ru
  3. +1 −1 examples/local_repo.ru
  4. +16 −0 lib/stickler/repository/api.rb
  5. +8 −5 lib/stickler/repository/remote.rb
  6. +0 −29 spec/data/gemcutter/specifications/foo-1.0.0.gemspec
  7. +0 −31 spec/data/specifications/bar-1.0.0.gemspec
  8. +0 −32 spec/data/specifications/baz-3.1.4-java.gemspec
  9. +0 −31 spec/data/specifications/baz-3.1.4.gemspec
  10. +0 −31 spec/data/specifications/foo-1.0.0.gemspec
  11. +0 −32 spec/data/specifications/foo-2.0.0a.gemspec
  12. +0 −73 spec/index_spec_helpers.rb
  13. +0 −72 spec/middleware/local_spec.rb
  14. +0 −25 spec/middleware/not_found_spec.rb
  15. +0 −11 spec/paths_spec.rb
  16. +0 −192 spec/repository/api_behavior.rb
  17. +0 −37 spec/repository/api_spec.rb
  18. +0 −46 spec/repository/index_spec.rb
  19. +0 −49 spec/repository/local_spec.rb
  20. +0 −14 spec/repository/null_spec.rb
  21. +0 −86 spec/repository/remote_spec.rb
  22. +0 −2 spec/spec.opts
  23. +0 −24 spec/spec_helper.rb
  24. +0 −96 spec/spec_lite_spec.rb
  25. +2 −2 tasks/default.rake
  26. BIN {spec → test}/data/gemcutter/gems/foo-1.0.0.gem
  27. BIN {spec → test}/data/gems/bar-1.0.0.gem
  28. BIN {spec → test}/data/gems/baz-3.1.4-java.gem
  29. BIN {spec → test}/data/gems/baz-3.1.4.gem
  30. BIN {spec → test}/data/gems/foo-1.0.0.gem
  31. BIN {spec → test}/data/gems/foo-2.0.0a.gem
  32. +75 −0 test/index_test_helpers.rb
  33. +75 −0 test/middleware/test_local.rb
  34. +26 −0 test/middleware/test_not_found.rb
  35. +49 −0 test/repository/test_api.rb
  36. +208 −0 test/repository/test_api_behavior.rb
  37. +48 −0 test/repository/test_index.rb
  38. +60 −0 test/repository/test_local.rb
  39. +15 −0 test/repository/test_null.rb
  40. +26 −0 test/repository/test_remote.rb
  41. +39 −0 test/repository/test_remote_authenticated.rb
  42. +35 −0 test/stickler_test_server.rb
  43. +22 −0 test/test_paths.rb
  44. +90 −0 test/test_spec_lite.rb
  45. +49 −0 test/test_stickler.rb
View
@@ -7,7 +7,7 @@ $:.unshift File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
require 'stickler'
-tmp = File.expand_path( File.join( File.dirname( __FILE__ ), "..", "spec", "data" ) )
+tmp = File.expand_path( File.join( File.dirname( __FILE__ ), "..", "test", "tmp" ) )
use Rack::Auth::Basic, 'Secure Stickler' do |u,p|
(u == "stickler") and (p == "secret")
@@ -12,7 +12,7 @@ $:.unshift File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
require 'stickler'
-gem_dir = File.expand_path( "../spec/tmp", File.dirname( __FILE__ ) )
+gem_dir = File.expand_path( "../test/tmp", File.dirname( __FILE__ ) )
use ::Stickler::Middleware::Compression
use ::Stickler::Middleware::Gemcutter, :repo_root => gem_dir
View
@@ -9,7 +9,7 @@ $:.unshift File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
require 'stickler/middleware/compression'
require 'stickler/middleware/local'
-gem_dir = File.expand_path( File.join( File.dirname( __FILE__ ), *%w[ .. spec data ]))
+gem_dir = File.expand_path( File.join( File.dirname( __FILE__ ), *%w[ .. test data ]))
puts gem_dir
use ::Stickler::Middleware::Compression
@@ -111,6 +111,22 @@ def yank( spec )
#
# :call-seq:
+ # repo.unyank( spec ) -> true or nil
+ #
+ # "unyank" in the sense of undoing "yank"
+ #
+ # This means, put the gem matching +spec+ back into the index so that it
+ # will be found during searching.
+ #
+ # If the gem is sucessfully put back into the index then true is returned.
+ # Otherwise nil is returned
+ #
+ def unyank( spec )
+ raise NotImplementedError, not_implemented_msg( :unyank )
+ end
+
+ #
+ # :call-seq:
# repo.get( spec ) -> bytes
#
# Retrieve the gem matching the spec from the repository. The bytes
@@ -95,12 +95,15 @@ def yank( spec )
#
# See Api#unyank
- #
+ #
def unyank( spec )
- return nil unless remote_gem_file_exist?( spec )
- query = { :spec_name => spec.name, :version => spec.version.to_s }
- resource_request( unyank_resource, :query => query )
- true
+ if remote_gem_file_exist?( spec ) && search_for( spec ).empty? then
+ query = { :spec_name => spec.name, :version => spec.version.to_s }
+ resource_request( unyank_resource, :query => query )
+ return true
+ else
+ return nil
+ end
rescue Excon::Errors::Error => e
raise Stickler::Repository::Error, "Failure unyanking: #{e.inspect}"
end
@@ -1,29 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "foo"
- s.version = "1.0.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = "2010-06-23"
- s.description = "foo gem"
- s.email = "jeremy@hinegardner.org"
- s.files = ["README.rdoc", "lib/foo.rb", "bin/foo", "Rakefile", "foo.gemspec"]
- s.homepage = "http://github.com/copiousfreetime/stickler"
- s.require_paths = ["lib"]
- s.rubygems_version = "1.8.21"
- s.summary = "foo gem"
-
- if s.respond_to? :specification_version then
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
@@ -1,31 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{bar}
- s.version = "1.0.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = %q{2010-06-23}
- s.description = %q{bar gem}
- s.email = %q{jeremy@hinegardner.org}
- s.files = ["README.rdoc", "lib/bar.rb", "bin/bar", "Rakefile", "bar.gemspec"]
- s.homepage = %q{http://github.com/copiousfreetime/stickler}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{bar gem}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
-
@@ -1,32 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{baz}
- s.version = "3.1.4"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = %q{2012-12-13}
- s.description = %q{baz gem}
- s.email = %q{jeremy@hinegardner.org}
- s.files = ["README.rdoc", "lib/baz.rb", "bin/baz", "Rakefile", "baz-3.1.4.gemspec"]
- s.homepage = %q{http://github.com/copiousfreetime/stickler}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{baz gem}
- s.platform = 'java'
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
-
@@ -1,31 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{baz}
- s.version = "3.1.4"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = %q{2012-12-13}
- s.description = %q{baz gem}
- s.email = %q{jeremy@hinegardner.org}
- s.files = ["README.rdoc", "lib/baz.rb", "bin/baz", "Rakefile", "baz-3.1.4.gemspec"]
- s.homepage = %q{http://github.com/copiousfreetime/stickler}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{baz gem}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
-
@@ -1,31 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{foo}
- s.version = "1.0.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = %q{2010-06-23}
- s.description = %q{foo gem}
- s.email = %q{jeremy@hinegardner.org}
- s.files = ["README.rdoc", "lib/foo.rb", "bin/foo", "Rakefile", "foo.gemspec"]
- s.homepage = %q{http://github.com/copiousfreetime/stickler}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{foo gem}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
-
@@ -1,32 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{foo}
- s.version = "2.0.0a"
-
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jeremy Hinegardner"]
- s.date = %q{2010-06-23}
- s.description = %q{foo gem prerelease}
- s.email = %q{jeremy@hinegardner.org}
- s.files = ["README.rdoc", "lib/foo.rb", "bin/foo", "Rakefile", "foo.gemspec"]
- s.has_rdoc = false
- s.homepage = %q{http://github.com/copiousfreetime/stickler}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{foo gem prerelease}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0"])
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
- else
- s.add_dependency(%q<rake>, [">= 0"])
- end
-end
-
View
@@ -1,73 +0,0 @@
-require 'rack/test'
-require 'rubygems/user_interaction'
-require 'rubygems/indexer'
-
-module IndexSpecHelpers
- include Rack::Test::Methods
-
- def define_directories
- # pristine spec data location
- @idx_spec_dir = File.expand_path( File.dirname( __FILE__ ) )
- @idx_spec_datadir = File.join( @idx_spec_dir, "data" )
-
- # scratch location
- @scratch_dir = File.join( @idx_spec_dir, "scratch" )
- @scratch_datadir = File.join( @scratch_dir, 'data' )
- @scratch_specdir = File.join( @scratch_datadir, "specifications" )
- @scratch_gemsdir = File.join( @scratch_datadir, "gems" )
- end
-
- # put in the before clause for setup
- def mirror_spec_gemdir
- define_directories
- FileUtils.mkdir_p( @scratch_dir )
- FileUtils.cp_r( @idx_spec_datadir, @scratch_dir )
- end
-
- # Do a legacy index of the scratch location
- def make_legacy_index
- indexer = Gem::Indexer.new( @scratch_datadir, :build_legacy => true, :build_modern => false )
- with_quieter_rubygems { indexer.generate_index }
- end
-
- # Do a modern index of the scratch location
- def make_modern_index
- indexer = Gem::Indexer.new( @scratch_datadir, :build_legacy => false, :build_modern => true )
- with_quieter_rubygems { indexer.generate_index }
- end
-
- # put in the after clause for cleanup
- def destroy_scratch_dir
- FileUtils.rm_rf( @scratch_dir )
- end
-
- def with_quieter_rubygems( &block )
- previous = Gem.configuration.verbose
- Gem.configuration.verbose = nil
- yield
- Gem.configuration.verbose = previous
- end
-
- def validate_contents( got, expected, content_type)
- case content_type
- when 'application/x-gzip'
- response_un = Gem.gunzip( got )
- expected_un = Gem.gunzip( expected )
- when 'application/x-deflate'
- response_un = Gem.inflate( got )
- expected_un = Gem.inflate( expected )
- when 'application/octet-stream'
- response_un = got
- expected_un = expected
- else
- fail "Unkonwn content type #{content_type} with data #{got}"
- end
-
- got = Marshal.load( response_un )
- got.sort! if got.kind_of?( Array )
-
- need = Marshal.load( expected_un )
- need.sort! if need.kind_of?( Array )
- got.should == need
- end
-end
Oops, something went wrong.

0 comments on commit 22ef228

Please sign in to comment.