1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Use __send__ instead of send

This commit is contained in:
Yukio Mizuta 2014-02-01 13:09:44 -08:00
parent 806716c79c
commit 90c4a7d215
9 changed files with 13 additions and 13 deletions

View file

@ -46,7 +46,7 @@ module Shoulda # :nodoc:
def redirects_to_url? def redirects_to_url?
begin begin
@context.send(:assert_redirected_to, url) @context.__send__(:assert_redirected_to, url)
@failure_message_when_negated = "Didn't expect to redirect to #{url}" @failure_message_when_negated = "Didn't expect to redirect to #{url}"
true true
rescue Shoulda::Matchers::AssertionError => error rescue Shoulda::Matchers::AssertionError => error

View file

@ -50,7 +50,7 @@ module Shoulda # :nodoc:
def renders_template? def renders_template?
begin begin
@context.send(:assert_template, @options, @message) @context.__send__(:assert_template, @options, @message)
@failure_message_when_negated = "Didn't expect to render #{@template}" @failure_message_when_negated = "Didn't expect to render #{@template}"
true true
rescue Shoulda::Matchers::AssertionError => error rescue Shoulda::Matchers::AssertionError => error

View file

@ -70,7 +70,7 @@ module Shoulda # :nodoc:
def route_recognized? def route_recognized?
begin begin
@context.send(:assert_routing, @context.__send__(:assert_routing,
{ method: @method, path: @path }, { method: @method, path: @path },
@params) @params)

View file

@ -68,7 +68,7 @@ module Shoulda # :nodoc:
values_to_match.none? do |value| values_to_match.none? do |value|
self.value = value self.value = value
instance.send("#{attribute_to_set}=", value) instance.__send__("#{attribute_to_set}=", value)
errors_match? errors_match?
end end
end end

View file

@ -158,7 +158,7 @@ module Shoulda # :nodoc:
end end
def find_outside_value def find_outside_value
case @subject.send(@attribute.to_s) case @subject.__send__(@attribute.to_s)
when Fixnum when Fixnum
ARBITRARY_OUTSIDE_FIXNUM ARBITRARY_OUTSIDE_FIXNUM
when BigDecimal when BigDecimal

View file

@ -6,7 +6,7 @@ module Shoulda # :nodoc:
obj.errors.map do |attribute, model| obj.errors.map do |attribute, model|
msg = "#{attribute} #{model}" msg = "#{attribute} #{model}"
if attribute.to_sym != :base && obj.respond_to?(attribute) if attribute.to_sym != :base && obj.respond_to?(attribute)
msg << " (#{obj.send(attribute).inspect})" msg << " (#{obj.__send__(attribute).inspect})"
end end
msg msg
end end

View file

@ -64,7 +64,7 @@ module Shoulda # :nodoc:
def set_confirmation(val) def set_confirmation(val)
setter = :"#{@confirmation_attribute}=" setter = :"#{@confirmation_attribute}="
if @subject.respond_to?(setter) if @subject.respond_to?(setter)
@subject.send(setter, val) @subject.__send__(setter, val)
end end
end end

View file

@ -114,7 +114,7 @@ module Shoulda # :nodoc:
end end
@subject.class.new.tap do |instance| @subject.class.new.tap do |instance|
instance.send("#{@attribute}=", value) instance.__send__("#{@attribute}=", value)
if has_secure_password? if has_secure_password?
instance.password = 'password' instance.password = 'password'
instance.password_confirmation = 'password' instance.password_confirmation = 'password'
@ -132,7 +132,7 @@ module Shoulda # :nodoc:
@options[:scopes].all? do |scope| @options[:scopes].all? do |scope|
setter = :"#{scope}=" setter = :"#{scope}="
if @subject.respond_to?(setter) if @subject.respond_to?(setter)
@subject.send(setter, existing_record.send(scope)) @subject.__send__(setter, existing_record.__send__(scope))
true true
else else
@failure_message = "#{class_name} doesn't seem to have a #{scope} attribute." @failure_message = "#{class_name} doesn't seem to have a #{scope} attribute."
@ -176,10 +176,10 @@ module Shoulda # :nodoc:
previous_value.to_s.next previous_value.to_s.next
end end
@subject.send("#{scope}=", next_value) @subject.__send__("#{scope}=", next_value)
if allows_value_of(existing_value, @expected_message) if allows_value_of(existing_value, @expected_message)
@subject.send("#{scope}=", previous_value) @subject.__send__("#{scope}=", previous_value)
@failure_message_when_negated << @failure_message_when_negated <<
" (with different value of #{scope})" " (with different value of #{scope})"
@ -209,7 +209,7 @@ module Shoulda # :nodoc:
end end
def existing_value def existing_value
value = existing_record.send(@attribute) value = existing_record.__send__(@attribute)
if @options[:case_insensitive] && value.respond_to?(:swapcase!) if @options[:case_insensitive] && value.respond_to?(:swapcase!)
value.swapcase! value.swapcase!
end end

View file

@ -104,7 +104,7 @@ describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher do
def with_table(column_name, column_type, options) def with_table(column_name, column_type, options)
create_table 'employees' do |table| create_table 'employees' do |table|
table.send(column_type, column_name, options) table.__send__(column_type, column_name, options)
end end
define_model_class('Employee').new define_model_class('Employee').new
end end