我想测试是否从foo调用方法foo1。这是我的代码
class C
def foo1
puts "called"
end
def foo
puts foo1
end
end
describe C
it "called"
expect(C.new.foo).to receive(:foo1)
end
end
但我在第expect(foo_).to receive(:foo1)
行上遇到错误:
syntax error, unexpected keyword_end, expecting end-of-input
答案 0 :(得分:0)
以下是您的代码的固定版本:
class C
def foo1
puts "called"
end
def foo
puts foo1
end
end
describe C do
it "called" do
c = C.new
expect(c).to receive(:foo1)
c.foo
end
end
describe
和it
块需要完整的do ... end
语法才能成为有效的语言。