Permalink
Browse files

Test that exception is thrown in Rails < 3.1

AbstractAdapter doesn't provide the required payload information until
3.1. Raising of the exception was moved out of the filter_query method
because the exception was being thrown during evaluation of the
subscribe block which prevented the eventual call to unsubscribe and
potentially failing other unrelated specs.
  • Loading branch information...
1 parent 8e7fbc5 commit 56de191d4e145114d41971852421185d165a34f2 @MDaubs MDaubs committed with Gabe Berke-Williams Mar 21, 2012
@@ -44,6 +44,8 @@ def or_less
end
def matches?(subject)
+ raise "Rails 3.1 or greater is required" unless rails_3_1?
+
@queries = []
subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |name, started, finished, id, payload|
@@ -88,7 +90,6 @@ def friendly_queries
end
def filter_query(query_name)
- raise "Rails 3.1 or greater is required" unless rails_3_1?
query_name == 'SCHEMA'
end
@@ -49,6 +49,14 @@ def self.count(arguments)
model.should_not query_the_database.when_calling(:count).with("arguments")
end
+ else
+
+ it "should raise an exception on Rails < 3.1" do
+ lambda {
+ @parent.should query_the_database(1.times).when_calling(:count)
+ }.should raise_exception
+ end
+
end
end

0 comments on commit 56de191

Please sign in to comment.