Permalink
Browse files

Get rid of ActiveRecord constant in spec_helper

Now none of the Rails constants are defined globally for specs - possible to properly test the case where it is not a Rails app.
  • Loading branch information...
1 parent 8e77927 commit d802f1b2c5909059938882cfcffbab42b798b96d @knzconnor knzconnor committed Mar 28, 2010
Showing with 10 additions and 5 deletions.
  1. +10 −0 spec/rack/bug/panels/sql_panel_spec.rb
  2. +0 −5 spec/spec_helper.rb
@@ -5,6 +5,16 @@ class Rack::Bug
before do
SQLPanel.reset
rack_env "rack-bug.panel_classes", [SQLPanel]
+
+ unless defined?(ActiveRecord)
+ @added_rails = true
+ Object.const_set :ActiveRecord, Module.new
+ ActiveRecord.const_set :Base, Class.new
+ end
+ end
+
+ after do
+ Object.send :remove_const, :ActiveRecord if @added_active_record
end
describe "heading" do
View
@@ -10,11 +10,6 @@
require "spec/fixtures/sample_app"
require "spec/fixtures/dummy_panel"
-module ActiveRecord
- class Base
- end
-end
-
Spec::Runner.configure do |config|
TIME_MS_REGEXP = /\d+\.\d{2}ms/

0 comments on commit d802f1b

Please sign in to comment.