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.
This commit is contained in:
parent
8e7fbc553b
commit
56de191d4e
|
@ -44,6 +44,8 @@ module Shoulda # :nodoc:
|
|||
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 @@ module Shoulda # :nodoc:
|
|||
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 @@ describe Shoulda::Matchers::ActiveRecord::QueryTheDatabaseMatcher do
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue