Skip to content

Commit

Permalink
Remove redundant to_sym in Mockery
Browse files Browse the repository at this point in the history
- Object#respond_to? has always accepted either string or symbol
  interchangeably (at least from Ruby v1.8.4 onwards).

- Mocha::ClassMethods__method_exists__? accepts either string or symbol
  since it uses Module#public_method_defined?,
  #protected_method_defined? & private_method_defined? which have
  accepted either string or symbol interchangeably (at least from Ruby
  v1.8.4 onwards), c.f. 9705028.
  • Loading branch information
nitishr authored and floehopper committed Aug 31, 2022
1 parent 9a22aa1 commit edb5f8d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mocha/mockery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ def mocha_inspect
end

def on_stubbing(object, method)
method = method.to_sym
signature_proc = lambda { "#{object.mocha_inspect}.#{method}" }
check(:stubbing_non_existent_method, 'non-existent method', signature_proc) do
!(object.stubba_class.__method_exists__?(method, true) || object.respond_to?(method.to_sym))
!(object.stubba_class.__method_exists__?(method, true) || object.respond_to?(method))
end
check(:stubbing_non_public_method, 'non-public method', signature_proc) do
object.stubba_class.__method_exists__?(method, false)
Expand Down

0 comments on commit edb5f8d

Please sign in to comment.