i have a code in ruby 2.7.2 where it is working fine. but after changing ruby version to 3.0.0 it is giving cannot modify FrozenObject error at line 275. as i have checked $? is a Frozen Object in ruby 3.0.0 but it is not Frozen in ruby 2.7.2 so what should i do? is there any alternative to this.
272: it 'returns the exitstatus of the command' do
273: allow(subject).to receive(:system)
274:
=> 275: allow($?).to receive(:exitstatus) { 42 }
276:
277:
278: expect(subject.copy_to('local', 'remote')).to eq(42)
279: end
1) xxxxxxxxxx::InstanceSSH#copy_to returns the exitstatus of the command
Failure/Error: allow($?.exitstatus).to receive(:exitstatus) { 42 }
FrozenError:
can't modify frozen object: pid 74171 exit 0
# ./spec/cloudgate/instance_ssh_spec.rb:275:in `block (3 levels) in <top (required)>'
# /home/lenovo/.rvm/gems/ruby-3.0.0/gems/webmock-3.10.0/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
Finished in 114 minutes 1 second (files took 1.81 seconds to load) 1 example, 1 failure