Sha256: d1356e1b90855367620d1aeeb1f1bd1f65324eadd302e838d2fc64b9eeffcbd7
Contents?: true
Size: 1.28 KB
Versions: 32
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' module Spree describe DisplayMoney do let(:test_class) do Class.new do extend DisplayMoney def total; 10.0; end end end describe ".money_methods" do before { test_class.money_methods :total } context "currency is not defined" do it "generates a display_method that builds a Spree::Money without options" do expect(test_class.new.display_total).to eq Spree::Money.new(10.0) end end context "currency is defined" do before { test_class.class_eval { def currency; "USD"; end } } it "generates a display_* method that builds a Spree::Money with currency" do expect(test_class.new.display_total).to eq Spree::Money.new(10.0, currency: "USD") end end context "with multiple + options" do before do test_class.class_eval { def amount; 20.0; end } test_class.money_methods :total, amount: { no_cents: true } end it "generates a display_* method that builds a Spree::Money with the specified options" do expect(test_class.new.display_total).to eq Spree::Money.new(10.0) expect(test_class.new.display_amount).to eq Spree::Money.new(20.0, no_cents: true) end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems