Skip to content

Commit

Permalink
Removed deprecated functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Feb 13, 2010
1 parent 975bf8a commit 324bbe9
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 446 deletions.
15 changes: 3 additions & 12 deletions lib/shoulda/action_controller/macros.rb
Expand Up @@ -27,23 +27,14 @@ module Macros
# Macro that creates a test asserting that the flash contains the given
# value. Expects a +String+ or +Regexp+.
#
# If the argument is +nil+, it will assert that the flash is not set.
# This behavior is deprecated.
#
# Example:
#
# should_set_the_flash_to "Thank you for placing this order."
# should_set_the_flash_to /created/i
def should_set_the_flash_to(val)
if val
matcher = set_the_flash.to(val)
should matcher.description do
assert_accepts matcher, @controller
end
else
warn "[DEPRECATION] should_set_the_flash_to nil is deprecated. " <<
"Use should_not_set_the_flash instead."
should_not_set_the_flash
matcher = set_the_flash.to(val)
should matcher.description do
assert_accepts matcher, @controller
end
end

Expand Down
10 changes: 0 additions & 10 deletions lib/shoulda/action_view.rb

This file was deleted.

61 changes: 0 additions & 61 deletions lib/shoulda/action_view/macros.rb

This file was deleted.

58 changes: 0 additions & 58 deletions lib/shoulda/active_record/macros.rb
Expand Up @@ -430,20 +430,6 @@ def should_have_db_indices(*columns)

alias_method :should_have_db_index, :should_have_db_indices

# Deprecated. See should_have_db_index
def should_have_index(*args)
warn "[DEPRECATION] should_have_index is deprecated. " <<
"Use should_have_db_index instead."
should_have_db_index(*args)
end

# Deprecated. See should_have_db_indices
def should_have_indices(*args)
warn "[DEPRECATION] should_have_indices is deprecated. " <<
"Use should_have_db_indices instead."
should_have_db_indices(*args)
end

# Ensures that the model cannot be saved if one of the attributes listed is not accepted.
#
# Options:
Expand All @@ -463,50 +449,6 @@ def should_validate_acceptance_of(*attributes)
end
end
end

# Deprecated.
#
# Ensures that the model has a method named scope_name that returns a NamedScope object with the
# proxy options set to the options you supply. scope_name can be either a symbol, or a method
# call which will be evaled against the model. The eval'd method call has access to all the same
# instance variables that a should statement would.
#
# Options: Any of the options that the named scope would pass on to find.
#
# Example:
#
# should_have_named_scope :visible, :conditions => {:visible => true}
#
# Passes for
#
# named_scope :visible, :conditions => {:visible => true}
#
# Or for
#
# def self.visible
# scoped(:conditions => {:visible => true})
# end
#
# You can test lambdas or methods that return ActiveRecord#scoped calls:
#
# should_have_named_scope 'recent(5)', :limit => 5
# should_have_named_scope 'recent(1)', :limit => 1
#
# Passes for
# named_scope :recent, lambda {|c| {:limit => c}}
#
# Or for
#
# def self.recent(c)
# scoped(:limit => c)
# end
#
def should_have_named_scope(scope_call, find_options = nil)
matcher = have_named_scope(scope_call).finding(find_options)
should matcher.description do
assert_accepts matcher.in_context(self), subject
end
end
end
end
end
1 change: 0 additions & 1 deletion lib/shoulda/active_record/matchers.rb
Expand Up @@ -13,7 +13,6 @@
require 'shoulda/active_record/matchers/have_db_index_matcher'
require 'shoulda/active_record/matchers/have_readonly_attribute_matcher'
require 'shoulda/active_record/matchers/allow_mass_assignment_of_matcher'
require 'shoulda/active_record/matchers/have_named_scope_matcher'


module Shoulda # :nodoc:
Expand Down
128 changes: 0 additions & 128 deletions lib/shoulda/active_record/matchers/have_named_scope_matcher.rb

This file was deleted.

25 changes: 1 addition & 24 deletions lib/shoulda/context.rb
Expand Up @@ -214,19 +214,6 @@ module InstanceMethods
# end
# end
#
# If an instance variable exists named after the described class, that
# instance variable will be used as the subject. This behavior is
# deprecated, and will be removed in a future version of Shoulda. The
# recommended approach for using a different subject is to use the subject
# class method.
#
# class UserTest
# should "be the existing user" do
# @user = User.new
# assert_equal @user, subject # passes
# end
# end
#
# The subject is used by all macros that require an instance of the class
# being tested.
def subject
Expand All @@ -239,17 +226,7 @@ def subject_block # :nodoc:

def get_instance_of(object_or_klass) # :nodoc:
if object_or_klass.is_a?(Class)
klass = object_or_klass
ivar = "@#{instance_variable_name_for(klass)}"
if instance = instance_variable_get(ivar)
warn "[WARNING] Using #{ivar} as the subject. Future versions " <<
"of Shoulda will require an explicit subject using the " <<
"subject class method. Add this after your setup to avoid " <<
"this warning: subject { #{ivar} }"
instance
else
klass.new
end
object_or_klass.new
else
object_or_klass
end
Expand Down
22 changes: 4 additions & 18 deletions lib/shoulda/macros.rb
Expand Up @@ -41,17 +41,10 @@ def should_change(description, options = {}, &block)
stmt << " to #{to.inspect}" if to
stmt << " by #{by.inspect}" if by

if block_given?
code = block
else
warn "[DEPRECATION] should_change(expression, options) is deprecated. " <<
"Use should_change(description, options) { code } instead."
code = lambda { eval(description) }
end
before = lambda { @_before_should_change = code.bind(self).call }
before = lambda { @_before_should_change = block.bind(self).call }
should stmt, :before => before do
old_value = @_before_should_change
new_value = code.bind(self).call
new_value = block.bind(self).call
assert_operator from, :===, old_value, "#{description} did not originally match #{from.inspect}" if from
assert_not_equal old_value, new_value, "#{description} did not change" unless by == 0
assert_operator to, :===, new_value, "#{description} was not changed to match #{to.inspect}" if to
Expand All @@ -72,16 +65,9 @@ def should_change(description, options = {}, &block)
# should_not_change("the number of posts") { Post.count }
# end
def should_not_change(description, &block)
if block_given?
code = block
else
warn "[DEPRECATION] should_not_change(expression) is deprecated. " <<
"Use should_not_change(description) { code } instead."
code = lambda { eval(description) }
end
before = lambda { @_before_should_not_change = code.bind(self).call }
before = lambda { @_before_should_not_change = block.bind(self).call }
should "not change #{description}", :before => before do
new_value = code.bind(self).call
new_value = block.bind(self).call
assert_equal @_before_should_not_change, new_value, "#{description} changed"
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/shoulda/rails.rb
Expand Up @@ -4,7 +4,6 @@

require 'shoulda/active_record' if defined? ActiveRecord::Base
require 'shoulda/action_controller' if defined? ActionController::Base
require 'shoulda/action_view' if defined? ActionView::Base
require 'shoulda/action_mailer' if defined? ActionMailer::Base

if defined?(RAILS_ROOT)
Expand Down

0 comments on commit 324bbe9

Please sign in to comment.