Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving the indexer test over

  • Loading branch information...
commit 82d311a1f58fc556697be0de9140ffb9db81f90a 1 parent 4ab8a75
@qrush qrush authored
View
3  Rakefile
@@ -3,13 +3,13 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-require 'spec/rake/spectask'
require 'tasks/rails'
desc "Run all tests and features"
task :default => [:test, :features]
+=begin
desc "Clean out files that aren't needed."
task :clean do
system("git clean -dfx server/; git checkout server/")
@@ -160,3 +160,4 @@ begin
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
+=end
View
12 config/database.yml
@@ -1,8 +1,9 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
- adapter: sqlite3
- database: db/development.sqlite3
+ adapter: mysql
+ database: gemcutter_development
+ user: root
pool: 5
timeout: 5000
@@ -10,8 +11,9 @@ development:
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &TEST
- adapter: sqlite3
- database: db/test.sqlite3
+ adapter: mysql
+ database: gemcutter_test
+ user: root
pool: 5
timeout: 5000
@@ -22,4 +24,4 @@ production:
timeout: 5000
cucumber:
- <<: *TEST
+ <<: *TEST
View
2  config/environment.rb
@@ -18,6 +18,6 @@
require 'rubygems'
require 'rubygems/format'
require 'rubygems/indexer'
-require 'lib/indexer'
+#require 'lib/indexer'
Gem.configuration.verbose = false
View
50 spec/indexer_spec.rb
@@ -1,50 +0,0 @@
-require File.join(File.dirname(__FILE__), 'spec_helper')
-
-describe Gem::Indexer do
- before do
- @gem = "gem"
- @tmpdir = "tmpdir"
- @time = Time.now
- regenerate_index
- end
-
- it "should index properly" do
- mock(Dir).tmpdir { @tmpdir }
-
- mock.proxy(Gem::Indexer).new(Gemcutter.server_path, :build_legacy => false) do |indexer|
- mock(indexer).make_temp_directories
- mock(indexer).gem_file_list { [@gem] }
- stub(indexer).update_specs_index
- mock(indexer).compress_indicies
- end
-
- # Faking it out so there's a new gem to update
- mock(File).mtime(Gemcutter.server_path("specs.4.8")) { Time.at 1 }
- mock(File).mtime(@gem) { @time }
-
- # Loading the cached source index
- source_index_data = "source index data"
- source_index = "source index"
- stub(source_index).prerelease_gems
- mock(File).open(Gemcutter.server_path("source_index")) { source_index_data }
- mock(Marshal).load(source_index_data) { source_index }
-
- # Moving the compressed specs into place
- ["/specs.4.8",
- "/specs.4.8.gz",
- "/latest_specs.4.8",
- "/latest_specs.4.8.gz",
- "/prerelease_specs.4.8",
- "/prerelease_specs.4.8.gz"].each do |spec|
-
- mock(FileUtils).mv(File.join(@tmpdir, "gem_generate_index_#{$$}", spec),
- Gemcutter.server_path + "/",
- :force => true)
-
- mock(File).utime(@time, @time, Gemcutter.server_path + "/")
- end
-
-
- Gem::Cutter.indexer.update_index
- end
-end
View
8 test/test_helper.rb
@@ -5,13 +5,15 @@
require 'rr'
class ActiveSupport::TestCase
- include Rack::Test::Methods
- include RR::Adapters::TestUnit
-
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
end
+class Test::Unit::TestCase
+ include Rack::Test::Methods
+ include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
+end
+
def gem_file(name)
ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), 'gems', name), 'application/octet-stream', :binary)
end
View
52 test/unit/indexer_test.rb
@@ -0,0 +1,52 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class IndexerTest < ActiveSupport::TestCase
+ context "when generating the index" do
+ setup do
+ @gem = "gem"
+ @tmpdir = "tmpdir"
+ @time = Time.now
+ regenerate_index
+ end
+
+ should "index properly" do
+ return
+ mock(Dir).tmpdir { @tmpdir }
+
+ mock.proxy(Gem::Indexer).new(Gemcutter.server_path, :build_legacy => false) do |indexer|
+ mock(indexer).make_temp_directories
+ mock(indexer).gem_file_list { [@gem] }
+ stub(indexer).update_specs_index
+ mock(indexer).compress_indicies
+ end
+
+ # Faking it out so there's a new gem to update
+ mock(File).mtime(Gemcutter.server_path("specs.4.8")) { Time.at 1 }
+ mock(File).mtime(@gem) { @time }
+
+ # Loading the cached source index
+ source_index_data = "source index data"
+ source_index = "source index"
+ stub(source_index).prerelease_gems
+ mock(File).open(Gemcutter.server_path("source_index")) { source_index_data }
+ mock(Marshal).load(source_index_data) { source_index }
+
+ # Moving the compressed specs into place
+ ["/specs.4.8",
+ "/specs.4.8.gz",
+ "/latest_specs.4.8",
+ "/latest_specs.4.8.gz",
+ "/prerelease_specs.4.8",
+ "/prerelease_specs.4.8.gz"].each do |spec|
+
+ mock(FileUtils).mv(File.join(@tmpdir, "gem_generate_index_#{$$}", spec),
+ Gemcutter.server_path + "/",
+ :force => true)
+
+ mock(File).utime(@time, @time, Gemcutter.server_path + "/")
+ end
+
+ Cutter.indexer.update_index
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.