【发布时间】:2013-11-02 13:54:08
【问题描述】:
我有这个代码:
adapter.send(:conditions_to_fields, :user => user).should == {'owner_id' => user.id}
我更新为使用期望:
expect(adapter.send(:conditions_to_fields, :user => user)).to eq {'owner_id' => user.id}
但这给了我:
syntax error, unexpected =>, expecting '}'
... => user)).to eq {'owner_id' => user.id}
我的代码有什么遗漏或错误导致该错误? 这是一个普遍的问题吗?
【问题讨论】:
-
为什么在.should matcher 看起来更干净且有效时使用“expect”? :S
-
@arieljuod 因为
should不是首选语法,所以expect是。请参阅RSpec’s New Expectation Syntax(由 RSpec 的一位核心贡献者提供)。