Deprecrate matchers for 2.0
This commit is contained in:
parent
e5914f75c1
commit
7beec816c7
|
@ -2,19 +2,7 @@ module Shoulda # :nodoc:
|
|||
module Matchers
|
||||
module ActionController # :nodoc:
|
||||
|
||||
# Ensures that the controller assigned to the named instance variable.
|
||||
#
|
||||
# Options:
|
||||
# * <tt>with_kind_of</tt> - The expected class of the instance variable
|
||||
# being checked.
|
||||
# * <tt>with</tt> - The value that should be assigned.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# it { should assign_to(:user) }
|
||||
# it { should_not assign_to(:user) }
|
||||
# it { should assign_to(:user).with_kind_of(User) }
|
||||
# it { should assign_to(:user).with(@user) }
|
||||
# DEPRECATED - This matcher will be removed in ShouldaMatchers 2.0, please remove all references to it.
|
||||
def assign_to(variable)
|
||||
AssignToMatcher.new(variable)
|
||||
end
|
||||
|
@ -23,6 +11,7 @@ module Shoulda # :nodoc:
|
|||
attr_reader :failure_message, :negative_failure_message
|
||||
|
||||
def initialize(variable)
|
||||
ActiveSupport::Deprecation.warn("'assign_to' will be removed in ShouldaMatchers 2.0.")
|
||||
@variable = variable.to_s
|
||||
@options = {}
|
||||
@options[:check_value] = false
|
||||
|
|
|
@ -2,27 +2,14 @@ module Shoulda # :nodoc:
|
|||
module Matchers
|
||||
module ActionController # :nodoc:
|
||||
|
||||
# Ensures a controller responded with expected 'response' content type.
|
||||
#
|
||||
# You can pass an explicit content type such as 'application/rss+xml'
|
||||
# or its symbolic equivalent :rss
|
||||
# or a regular expression such as /rss/
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# it { should respond_with_content_type(:xml) }
|
||||
# it { should respond_with_content_type(:csv) }
|
||||
# it { should respond_with_content_type(:atom) }
|
||||
# it { should respond_with_content_type(:yaml) }
|
||||
# it { should respond_with_content_type(:text) }
|
||||
# it { should respond_with_content_type('application/rss+xml') }
|
||||
# it { should respond_with_content_type(/json/) }
|
||||
# DEPRECATED - This matcher will be removed in ShouldaMatchers 2.0, please remove all references to it.
|
||||
def respond_with_content_type(content_type)
|
||||
RespondWithContentTypeMatcher.new(content_type)
|
||||
end
|
||||
|
||||
class RespondWithContentTypeMatcher # :nodoc:
|
||||
def initialize(content_type)
|
||||
ActiveSupport::Deprecation.warn("'respond_with_content_type' will be removed in ShouldaMatchers 2.0.")
|
||||
@content_type = look_up_content_type(content_type)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,21 +2,7 @@ module Shoulda # :nodoc:
|
|||
module Matchers
|
||||
module ActionMailer # :nodoc:
|
||||
|
||||
# The right email is sent.
|
||||
#
|
||||
# it { should have_sent_email.with_subject(/is spam$/) }
|
||||
# it { should have_sent_email.from('do-not-reply@example.com') }
|
||||
# it { should have_sent_email.with_body(/is spam\./) }
|
||||
# it { should have_sent_email.to('myself@me.com') }
|
||||
# it { should have_sent_email.with_part('text/html', /HTML spam/) }
|
||||
# it { should have_sent_email.with_subject(/spam/).
|
||||
# from('do-not-reply@example.com').
|
||||
# reply_to('reply-to-me@example.com').
|
||||
# with_body(/spam/).
|
||||
# to('myself@me.com') }
|
||||
#
|
||||
# Use values of instance variables
|
||||
# it {should have_sent_email.to {@user.email} }
|
||||
# DEPRECATED - This matcher will be removed in ShouldaMatchers 2.0, please remove all references to it.
|
||||
def have_sent_email
|
||||
HaveSentEmailMatcher.new(self)
|
||||
end
|
||||
|
@ -24,6 +10,7 @@ module Shoulda # :nodoc:
|
|||
class HaveSentEmailMatcher # :nodoc:
|
||||
|
||||
def initialize(context)
|
||||
ActiveSupport::Deprecation.warn("'have_sent_email' will be removed in ShouldaMatchers 2.0.")
|
||||
@context = context
|
||||
end
|
||||
|
||||
|
|
|
@ -2,24 +2,14 @@ module Shoulda # :nodoc:
|
|||
module Matchers
|
||||
module ActiveRecord # :nodoc:
|
||||
|
||||
# Ensures that the number of database queries is known. Rails 3.1 or greater is required.
|
||||
#
|
||||
# Options:
|
||||
# * <tt>when_calling</tt> - Required, the name of the method to examine.
|
||||
# * <tt>with</tt> - Used in conjunction with <tt>when_calling</tt> to pass parameters to the method to examine.
|
||||
# * <tt>or_less</tt> - Pass if the database is queried no more than the number of times specified, as opposed to exactly that number of times.
|
||||
#
|
||||
# Examples:
|
||||
# it { should query_the_database(4.times).when_calling(:complicated_counting_method)
|
||||
# it { should query_the_database(4.times).or_less.when_calling(:generate_big_report)
|
||||
# it { should_not query_the_database.when_calling(:cached_count)
|
||||
#
|
||||
# DEPRECATED - This matcher will be removed in ShouldaMatchers 2.0, please remove all references to it.
|
||||
def query_the_database(times = nil)
|
||||
QueryTheDatabaseMatcher.new(times)
|
||||
end
|
||||
|
||||
class QueryTheDatabaseMatcher # :nodoc:
|
||||
def initialize(times)
|
||||
ActiveSupport::Deprecation.warn("'query_the_database' will be removed in ShouldaMatchers 2.0.")
|
||||
@queries = []
|
||||
@options = {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue