我正在关注一个教程并且遇到了一些错误,我相信一些语言已经过时了Rspec并且已经搞砸了很多尝试修复此问题但却无法解决。
我得到的错误是
NoMethodError:
undefined method `should_recieve' for #<Panda:0x007f9cd45c6458>
# ./spec/zookeeper_spec.rb:9:in `block (2 levels) in <top (required)>'
有问题的代码是
describe Zookeeper do
it "should be able to feed the bamboo to the pandas" do
panda = Panda.new
panda.should_recieve(:eat).with(:bamboo)
Zookeeper.new.feed(food: :bamboo, to: panda)
end
答案 0 :(得分:0)
我已经意识到should_recieve实际上应该是should_receive,这解决了这个问题。然后我用和期望替换了should_receive并接收
describe Zookeeper do
it "should be able to feed the bamboo to the pandas" do
panda = Panda.new
expect(panda).to receive(:eat).with(:bamboo)
Zookeeper.new.feed(food: :bamboo, to: panda)
end