Permalink
Browse files

Deprecrate matchers for 2.0

  • Loading branch information...
1 parent e5914f7 commit 7beec816c789e67241cec197a89854489f6d669c @drapergeek drapergeek committed Oct 5, 2012
@@ -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.
@calebthompson

calebthompson Oct 5, 2012

Shoulda::Matchers, isn't it?

@gabebw

gabebw Oct 5, 2012

Contributor

Yup, this should be either Shoulda::Matchers or (even better) shoulda-matchers.

def assign_to(variable)
AssignToMatcher.new(variable)
end
@@ -23,6 +11,7 @@ class AssignToMatcher # :nodoc:
attr_reader :failure_message, :negative_failure_message
def initialize(variable)
+ ActiveSupport::Deprecation.warn("'assign_to' will be removed in ShouldaMatchers 2.0.")
@calebthompson

calebthompson Oct 5, 2012

Is it worth offering an alternative call? I'm not sure what it would be, but generally that's what you would see in a Rails deprecation.

@gabebw

gabebw Oct 5, 2012

Contributor

We don't use this at all, though. We believe that there shouldn't be an alternative call, since it's not even in use (by us).

@calebthompson

calebthompson via email Oct 5, 2012

@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,28 +2,15 @@ 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
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 = {}

0 comments on commit 7beec81

Please sign in to comment.