Permalink
Browse files

individual methods still not working

  • Loading branch information...
1 parent 73308b5 commit 6d82cacb013fe7a20e1bbbb21186272ae9e83b7d @jnewland committed Feb 9, 2009
Showing with 8 additions and 97 deletions.
  1. +1 −0 config.ru
  2. +0 −2 lib/rack_rubygems.rb
  3. +4 −10 spec/rack_rubygems_spec.rb
  4. +3 −85 spec/spec_helper.rb
View
1 config.ru
@@ -3,4 +3,5 @@ $:.unshift LIB_PATH
require 'rack_rubygems'
use Rack::Lint
use GemsAndRdocs, :urls => ['/cache', '/doc'], :root => Gem.dir
+use Rack::Compress
run RackRubygems.new
View
2 lib/rack_rubygems.rb
@@ -9,8 +9,6 @@
class RackRubygems < Sinatra::Base
- use Rack::Compress
-
head "/Marshal.#{Gem.marshal_version}" do
content_type 'application/octet-stream'
response['Content-Length'] = source_index.length.to_s
View
14 spec/rack_rubygems_spec.rb
@@ -56,17 +56,11 @@
describe "provides access to individual gemspecs" do
it "via name and version" do
- should_match_webrick_behavior "/quick/a-1.gemspec.rz", :quick
+ should_match_webrick_behavior "/quick/rack-0.9.1.gemspec.rz", :quick
end
it "via name, version, and platform" do
- a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
- should_match_webrick_behavior "/quick/a-1-#{Gem::Platform.local}.gemspec.rz", :quick
- end
-
- it "performing substring matching" do
- ab1 = quick_gem 'ab', '1'
- should_match_webrick_behavior "/quick/ab-1.gemspec.rz", :quick
+ should_match_webrick_behavior "/quick/rack-0.9.1-#{Gem::Platform.local}.gemspec.rz", :quick
end
it "via a quick index" do
@@ -91,11 +85,11 @@
end
it "marshalled via name and version" do
- should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/a-1.gemspec.rz", :quick
+ should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/rack-0.9.1.gemspec.rz", :quick
end
it "marshalled via name, version, and platform" do
- should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz", :quick
+ should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/rack-0.9.1-#{Gem::Platform.local}.gemspec.rz", :quick
end
end
View
88 spec/spec_helper.rb
@@ -43,48 +43,6 @@ def should_match_webrick_behavior(url, server_method, method = :get)
}
end
- #stub gem
- def quick_gem(gemname, version='2')
- require 'rubygems/specification'
-
- spec = Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = gemname
- s.version = version
- s.author = 'A User'
- s.email = 'example@example.com'
- s.homepage = 'http://example.com'
- s.has_rdoc = true
- s.summary = "this is a summary"
- s.description = "This is a test description"
-
- yield(s) if block_given?
- end
-
- path = File.join "specifications", "#{spec.full_name}.gemspec"
- written_path = write_file path do |io|
- io.write(spec.to_ruby)
- end
-
- spec.loaded_from = written_path
-
- Gem.source_index.add_spec spec
-
- return spec
- end
-
- def write_file(path)
- path = File.join(@gemhome, path)
- dir = File.dirname path
- FileUtils.mkdir_p dir
-
- open path, 'wb' do |io|
- yield io
- end
-
- path
- end
-
def process_based_port
@@process_based_port ||= 8000 + $$ % 1000
end
@@ -94,58 +52,18 @@ def process_based_port
Spec::Runner.configure do |config|
config.before(:each) {
- tmpdir = nil
- Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
- @tempdir = File.join tmpdir, "test_rubygems_#{$$}"
- @tempdir.untaint
- @gemhome = File.join @tempdir, "gemhome"
- @gemcache = File.join(@gemhome, "source_cache")
- @usrcache = File.join(@gemhome, ".gem", "user_cache")
- @latest_usrcache = File.join(@gemhome, ".gem", "latest_user_cache")
- @userhome = File.join @tempdir, 'userhome'
-
- @orig_ENV_HOME = ENV['HOME']
- ENV['HOME'] = @userhome
- Gem.instance_variable_set :@user_home, nil
-
- FileUtils.mkdir_p @gemhome
- FileUtils.mkdir_p @userhome
-
- ENV['GEMCACHE'] = @usrcache
- Gem.use_paths(@gemhome)
- Gem.loaded_specs.clear
-
- Gem.configuration.verbose = true
- Gem.configuration.update_sources = true
-
- @gem_repo = "http://gems.example.com/"
- @uri = URI.parse @gem_repo
- Gem.sources.replace [@gem_repo]
-
- Gem::SpecFetcher.fetcher = nil
-
- @orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
- Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:RUBY_INSTALL_NAME]
-
- @orig_arch = Gem::ConfigMap[:arch]
-
- @marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
-
- @private_key = File.expand_path File.join(File.dirname(__FILE__), 'private_key.pem')
- @public_cert = File.expand_path File.join(File.dirname(__FILE__), 'public_cert.pem')
-
@app = Rack::Builder.new {
use GemsAndRdocs, :urls => ['/cache', '/doc'], :root => Gem.dir
+ use Rack::Compress
run RackRubygems.new
}
- @a1 = quick_gem 'a', '1'
- @a2 = quick_gem 'a', '2'
-
@webrick = Gem::Server.new Gem.dir, process_based_port, false
@webrick_request = WEBrick::HTTPRequest.new :Logger => nil
@webrick_response = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
+
}
+
config.include Sinatra::Test
config.include RackRubygemsTestHelpers
end

0 comments on commit 6d82cac

Please sign in to comment.