Sha256: 1426b0efaf2d48422d96233b09687cf7c9363c4457d3bd6a88b34d29881af9b5
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
# -*- encoding : utf-8 -*- require 'spec_helper' if defined? ActiveRecord describe 'TestHelpers' do require "money-rails/test_helpers" include MoneyRails::TestHelpers let(:product) do Product.create(:price_cents => 3000, :discount => 150, :bonus_cents => 200, :optional_price => 100, :sale_price_amount => 1200) end describe "monetize matcher" do it "matches model attribute without a '_cents' suffix by default" do product.should monetize(:price_cents) end it "matches model attribute specified by :as chain" do product.should monetize(:discount).as(:discount_value) end it "matches model attribute with currency specified by :with_currency chain" do product.should monetize(:bonus_cents).with_currency(:gbp) end it "does not match non existed attribute" do product.should_not monetize(:price_fake) end it "does not match wrong currency iso" do product.should_not monetize(:bonus_cents).with_currency(:usd) end it "does not match wrong money attribute name" do product.should_not monetize(:bonus_cents).as(:bonussss) end context "using subject" do subject { product } it { should monetize(:price_cents) } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
money-rails-0.11.0 | spec/test_helpers_spec.rb |
money-rails-0.10.0 | spec/test_helpers_spec.rb |
money-rails-0.9.0 | spec/test_helpers_spec.rb |