Browse files

defining Rails in global spec_helper is masking some dependencies and…

… making pure Rack testing hard
  • Loading branch information...
1 parent 64dc372 commit 8e77927aa320b20d57444caf502c38d7ad0e5281 @knzconnor knzconnor committed Mar 27, 2010
Showing with 23 additions and 12 deletions.
  1. +8 −0 spec/rack/bug/panels/cache_panel_spec.rb
  2. +15 −0 spec/rack/bug/panels/rails_info_panel_spec.rb
  3. +0 −12 spec/spec_helper.rb
View
8 spec/rack/bug/panels/cache_panel_spec.rb
@@ -5,6 +5,14 @@ class Rack::Bug
before do
CachePanel.reset
rack_env "rack-bug.panel_classes", [CachePanel]
+ unless defined?(Rails)
+ @added_rails = true
+ Object.const_set :Rails, Module.new
+ end
+ end
+
+ after do
+ Object.send :remove_const, :Rails if @added_rails
end
describe "heading" do
View
15 spec/rack/bug/panels/rails_info_panel_spec.rb
@@ -4,6 +4,20 @@ class Rack::Bug
describe RailsInfoPanel do
before do
rack_env "rack-bug.panel_classes", [RailsInfoPanel]
+
+ unless defined?(Rails)
+ @added_rails = true
+ Object.const_set :Rails, Module.new
+ Rails::Info = Class.new do
+ def self.properties
+ []
+ end
+ end
+ end
+ end
+
+ after do
+ Object.send :remove_const, :Rails if @added_rails
end
describe "heading" do
@@ -16,6 +30,7 @@ class Rack::Bug
describe "content" do
it "displays the Rails::Info properties" do
+ Rails.stub!(:version => "v2.3.0")
Rails::Info.stub!(:properties => [["Name", "Value"]])
response = get_via_rack "/"
response.should have_row("#rails_info", "Name", "Value")
View
12 spec/spec_helper.rb
@@ -10,18 +10,6 @@
require "spec/fixtures/sample_app"
require "spec/fixtures/dummy_panel"
-module Rails
- def self.version
- ""
- end
-
- class Info
- def self.properties
- []
- end
- end
-end
-
module ActiveRecord
class Base
end

0 comments on commit 8e77927

Please sign in to comment.