1

我在 ruby​​ 2.7.2 中有一个代码,它工作正常。但是在将 ruby​​ 版本更改为 3.0.0 后,它在第 275 行给出了无法修改 FrozenObject 错误。因为我检查了 $? 在 ruby​​ 3.0.0 中是 Frozen Object,但在 ruby​​ 2.7.2 中不是 Frozen,所以我该怎么办?有没有其他选择。

   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)>'

在 114 分 1 秒内完成(文件加载时间为 1.81 秒) 1 个示例,1 个失败

4

0 回答 0