How to check block is called using rspec
问题 I want to check whether the block is called in my function using rspec. Below is my code: class SP def speak(options={},&block) puts "speak called" block.call() rescue ZeroDivisionError => e end end describe SP do it "testing speak functionality can receive a block" do sp = SP.new def test_func a = 1 end sp_mock = double(sp) expect(sp_mock).to receive(:speak).with(test_func) sp.speak(test_func) end end Below is my error: SP testing speak functionality can receive a block Failure/Error: block