Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我预计以下工作
expect(UserUpdateService).to receive(:new)
但它令人期待
undefined method `receive' for #<RSpec::Core::ExampleGroup::Nested_1:0x007faa044d42d8>
但是,“旧”语法有效:
UserUpdateService.should_receive(:new)
知道为什么第一个/新语法会引发异常吗?
此示例通过 rspec 2.14.1
specify do expect(UserUpdateService).to receive(:new) UserUpdateService.new end