Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Remove misleading frozen string check from proxy
Browse files Browse the repository at this point in the history
Let the logic in method_double handle this like it does for other
classes.
  • Loading branch information
keegangroth committed May 2, 2022
1 parent 07d2e20 commit be94530
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
9 changes: 2 additions & 7 deletions lib/rspec/mocks/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ def initialize(object, order_group, options={})

# @private
def ensure_can_be_proxied!(object)
return unless object.is_a?(Symbol) || (object.is_a?(String) && object.frozen?)
return unless object.is_a?(Symbol)

msg = "Cannot proxy frozen objects"
if Symbol === object
msg << ". Symbols such as #{object} cannot be mocked or stubbed."
else
msg << ", rspec-mocks relies on proxies for method stubbing and expectations."
end
msg = "Cannot proxy frozen objects. Symbols such as #{object} cannot be mocked or stubbed."
raise ArgumentError, msg
end

Expand Down
8 changes: 0 additions & 8 deletions spec/rspec/mocks/space_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ def create_generations
expect { space1.proxy_for(object) }.to raise_error(ArgumentError, expected_message)
end

it 'raises ArgumentError with message if object is frozen' do
space1 = Space.new
object = "subject".freeze
expected_message = "Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations."

expect { space1.proxy_for(object) }.to raise_error(ArgumentError, expected_message)
end

def in_new_space_scope
RSpec::Mocks.setup
yield
Expand Down

0 comments on commit be94530

Please sign in to comment.