这里是Ruby on Rails的新手。
我正在使用金钢石做一个资金支持的应用程序。我想测试一下货币市场。
阅读spec.rb,有
let(:product) do
Product.create(:price_cents => 3000, :discount => 150,
:bonus_cents => 200,
:sale_price_amount => 1200)
end
...
describe "monetize matcher" do
...
it "matches model attribute with currency specified by :with_currency chain" do
product.should monetize(:bonus_cents).with_currency(:gbp)
end
...
end其中,相应的产品模型有
monetize :bonus_cents, :with_currency => :gbp所以测试通过了。我将如何按照最近的rspec的期望(.)语法重写该测试?我会试着
expect(monetize(:bonus_cents).with_currency(:gbp)).to be true但失败了。
发布于 2014-08-31 06:46:13
product.should monetize(:bonus_cents).with_currency(:gbp)发表意见如下:
expect(product).to monetize(:bonus_cents).with_currency(:gbp)expect只是封装正在测试的对象,其余的匹配器通常是相同的。
https://stackoverflow.com/questions/25589482
复制相似问题