Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

properly mock out the gem index

  • Loading branch information...
commit a4ee19bad1be5514c7072f7c630a872ae38cf54e 1 parent 304927e
Jesse Newland authored February 21, 2009
35  spec/gems/sinatra-0.9.0.4.gemspec
... ...
@@ -0,0 +1,35 @@
  1
+# -*- encoding: utf-8 -*-
  2
+
  3
+Gem::Specification.new do |s|
  4
+  s.name = %q{sinatra}
  5
+  s.version = "0.9.0.4"
  6
+
  7
+  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  8
+  s.authors = ["Blake Mizerany"]
  9
+  s.date = %q{2009-01-25}
  10
+  s.description = %q{Classy web-development dressed in a DSL}
  11
+  s.email = %q{sinatrarb@googlegroups.com}
  12
+  s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
  13
+  s.files = ["AUTHORS", "CHANGES", "LICENSE", "README.rdoc", "Rakefile", "compat/app_test.rb", "compat/application_test.rb", "compat/builder_test.rb", "compat/compat_test.rb", "compat/custom_error_test.rb", "compat/erb_test.rb", "compat/events_test.rb", "compat/filter_test.rb", "compat/haml_test.rb", "compat/helper.rb", "compat/mapped_error_test.rb", "compat/pipeline_test.rb", "compat/public/foo.xml", "compat/sass_test.rb", "compat/sessions_test.rb", "compat/streaming_test.rb", "compat/sym_params_test.rb", "compat/template_test.rb", "compat/use_in_file_templates_test.rb", "compat/views/foo.builder", "compat/views/foo.erb", "compat/views/foo.haml", "compat/views/foo.sass", "compat/views/foo_layout.erb", "compat/views/foo_layout.haml", "compat/views/layout_test/foo.builder", "compat/views/layout_test/foo.erb", "compat/views/layout_test/foo.haml", "compat/views/layout_test/foo.sass", "compat/views/layout_test/layout.builder", "compat/views/layout_test/layout.erb", "compat/views/layout_test/layout.haml", "compat/views/layout_test/layout.sass", "compat/views/no_layout/no_layout.builder", "compat/views/no_layout/no_layout.haml", "lib/sinatra.rb", "lib/sinatra/base.rb", "lib/sinatra/compat.rb", "lib/sinatra/images/404.png", "lib/sinatra/images/500.png", "lib/sinatra/main.rb", "lib/sinatra/test.rb", "lib/sinatra/test/bacon.rb", "lib/sinatra/test/rspec.rb", "lib/sinatra/test/spec.rb", "lib/sinatra/test/unit.rb", "sinatra.gemspec", "test/base_test.rb", "test/builder_test.rb", "test/data/reload_app_file.rb", "test/erb_test.rb", "test/filter_test.rb", "test/haml_test.rb", "test/helper.rb", "test/helpers_test.rb", "test/mapped_error_test.rb", "test/middleware_test.rb", "test/options_test.rb", "test/reload_test.rb", "test/request_test.rb", "test/result_test.rb", "test/routing_test.rb", "test/sass_test.rb", "test/sinatra_test.rb", "test/static_test.rb", "test/templates_test.rb", "test/views/hello.builder", "test/views/hello.erb", "test/views/hello.haml", "test/views/hello.sass", "test/views/hello.test", "test/views/layout2.builder", "test/views/layout2.erb", "test/views/layout2.haml", "test/views/layout2.test"]
  14
+  s.has_rdoc = true
  15
+  s.homepage = %q{http://sinatra.rubyforge.org}
  16
+  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"]
  17
+  s.require_paths = ["lib"]
  18
+  s.rubyforge_project = %q{sinatra}
  19
+  s.rubygems_version = %q{1.3.1}
  20
+  s.summary = %q{Classy web-development dressed in a DSL}
  21
+  s.test_files = ["test/base_test.rb", "test/builder_test.rb", "test/erb_test.rb", "test/filter_test.rb", "test/haml_test.rb", "test/helpers_test.rb", "test/mapped_error_test.rb", "test/middleware_test.rb", "test/options_test.rb", "test/reload_test.rb", "test/request_test.rb", "test/result_test.rb", "test/routing_test.rb", "test/sass_test.rb", "test/sinatra_test.rb", "test/static_test.rb", "test/templates_test.rb"]
  22
+
  23
+  if s.respond_to? :specification_version then
  24
+    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
  25
+    s.specification_version = 2
  26
+
  27
+    if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
  28
+      s.add_runtime_dependency(%q<rack>, [">= 0.9.1"])
  29
+    else
  30
+      s.add_dependency(%q<rack>, [">= 0.9.1"])
  31
+    end
  32
+  else
  33
+    s.add_dependency(%q<rack>, [">= 0.9.1"])
  34
+  end
  35
+end
8  spec/rack_rubygems_spec.rb
@@ -78,11 +78,11 @@
78 78
 
79 79
   describe "provides access to individual gemspecs" do
80 80
     it "via name and version" do
81  
-      should_match_webrick_behavior "/quick/a-1.gemspec.rz", :quick
  81
+      should_match_webrick_behavior "/quick/sinatra-0.9.0.4.gemspec.rz", :quick
82 82
     end
83 83
 
84 84
     it "via name, version, and platform" do
85  
-      should_match_webrick_behavior "/quick/a-1-#{Gem::Platform.local}.gemspec.rz", :quick
  85
+      should_match_webrick_behavior "/quick/sinatra-0.9.0.4-#{Gem::Platform.local}.gemspec.rz", :quick
86 86
     end
87 87
 
88 88
     it "returns a 404 when accessing a missing gem" do
@@ -91,11 +91,11 @@
91 91
     end
92 92
 
93 93
     it "marshalled via name and version" do
94  
-      should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/a-1.gemspec.rz", :quick
  94
+      should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/sinatra-0.9.0.4.gemspec.rz", :quick
95 95
     end
96 96
 
97 97
     it "marshalled via name, version, and platform" do
98  
-      should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz", :quick
  98
+      should_match_webrick_behavior "/quick/Marshal.#{Gem.marshal_version}/sinatra-0.9.0.4-#{Gem::Platform.local}.gemspec.rz", :quick
99 99
     end
100 100
   end
101 101
 
7  spec/spec_helper.rb
@@ -43,11 +43,18 @@ def should_match_webrick_behavior(url, server_method, method = :get)
43 43
 
44 44
 Spec::Runner.configure do |config|
45 45
   config.before(:each) {
  46
+    #mock the gem index
  47
+    @source_index = Gem::SourceIndex.from_gems_in File.expand_path(File.dirname(__FILE__) + "/gems")
  48
+    Gem::SourceIndex.should_receive(:from_gems_in).any_number_of_times.and_return(@source_index.refresh!)
  49
+
  50
+    #sinatra
46 51
     @app = Rack::Builder.new {
47 52
       use GemsAndRdocs, :urls => ['/cache', '/doc'], :root => Gem.dir
48 53
       use Rack::Compress
49 54
       run RackRubygems.new
50 55
     }
  56
+
  57
+    #webrick
51 58
     @webrick = Gem::Server.new Gem.dir, (8000 + $$ % 1000), false
52 59
     @webrick_request = WEBrick::HTTPRequest.new :Logger => nil
53 60
     @webrick_response = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'

0 notes on commit a4ee19b

Please sign in to comment.
Something went wrong with that request. Please try again.