New to Ruby on Rails here.
I'm doing an application with money support using money-rails gem. I want to test the money locale.
Reading the gem's example at test_helpers_spec.rb, there is
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
where the respective Product model has
monetize :bonus_cents, :with_currency => :gbp
so the test passes. How would I would rewrite that test following the recent rspec's expect(...) syntax? I would try
expect(monetize(:bonus_cents).with_currency(:gbp)).to be true
but it fails.
product.should monetize(:bonus_cents).with_currency(:gbp)
Comes out to:
expect(product).to monetize(:bonus_cents).with_currency(:gbp)
expect
just wraps the object being tested, the rest of the matchers are generally the same.