Skip to content

Commit

Permalink
Removed v3.2.0 deprecations (references #31)
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Sep 19, 2010
2 parents 31214fe + 0c24d66 commit d579d11
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 189 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ Features
--------
- Added support for creating objects with the main monetary unit instead of cents.
([#issue/25](http://github.com/RubyMoney/money/issues/25))

Changes
-------
- Deprecated `Money#format` with separate params instead of Hash.
Deprecation target set to Money 3.5.0.
([#issue/31](http://github.com/RubyMoney/money/issues/31))
- Deprecated `Money#new(0, :currency => "EUR")` in favor of `Money#new(0, "EUR")`.
Deprecation target set to Money 3.5.0.
([#issue/31](http://github.com/RubyMoney/money/issues/31))

- Removed deprecated `Money::SYMBOLS`, `Money::SEPARATORS` and `Money::DELIMITERS`.
- Removed deprecated `Money::VariableExchangeBank`.
- Removed deprecated `Money::Bank::Base#exchange`.

Money 3.1.0
===========
Expand All @@ -23,7 +28,7 @@ Features
- Added `Money::Bank::Base#exchange_with`.
- Deprecated `Money::Bank::Base#exchange`. Deprecation target set to Money
3.2.0.
- Implented `Money::Bank::VariableExchange`
- Implemented `Money::Bank::VariableExchange`
- Deprecated `Money::VariableExchangeBank`. Deprecation target set to Money
3.2.0.
- Deprecate `Money::SYMBOLS`, `Money::SEPARATORS` and `Money::DELIMITERS`.
Expand Down
1 change: 0 additions & 1 deletion lib/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@

require 'money/currency'
require 'money/money'
require 'money/defaults'
require 'money/core_extensions'
require 'money/deprecations'
7 changes: 0 additions & 7 deletions lib/money/bank/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ def initialize(&block)
def setup
end

# @deprecated +#exchange+ will be removed in v3.2.0, use +#exchange_with+
# @see Money::Bank::Base#exchange_with
def exchange(cents, from_currency, to_currency, &block)
Money.deprecate "`Money::Bank::Base#exchange' will be removed in v3.2.0, use #exchange_with instead"
exchange_with(Money.new(cents, from_currency), to_currency, &block).cents
end

# Exchanges the given +Money+ object to a new +Money+ object in
# +to_currency+.
#
Expand Down
57 changes: 0 additions & 57 deletions lib/money/defaults.rb

This file was deleted.

14 changes: 0 additions & 14 deletions lib/money/deprecations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,4 @@ class Money
def self.deprecate(message)
warn "DEPRECATION WARNING: #{message}"
end


# Money::VariableExchangeBank is the legacy default bank
# shipped with Money. The class has been superseded by
# Money::Bank::VariableExchange.
#
# @deprecated Use Money::Bank::VariableExchange instead.
class VariableExchangeBank < Bank::VariableExchange # :nodoc:
# Calls +Money#deprecate+ the super.
def initialize(*args)
Money.deprecate "Money::VariableExchangeBank is deprecated and will be removed in v3.2.0. Use Money::Bank::VariableExchange instead."
super
end
end
end
6 changes: 0 additions & 6 deletions spec/bank/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ def setup
end
end

describe '#exchange' do
it 'should raise NotImplementedError' do
lambda { @bank.exchange(100, 'USD', 'EUR') }.should raise_exception(NotImplementedError)
end
end

describe '#exchange_with' do
it 'should raise NotImplementedError' do
lambda { @bank.exchange_with(Money.new(100, 'USD'), 'EUR') }.should raise_exception(NotImplementedError)
Expand Down
90 changes: 0 additions & 90 deletions spec/bank/variable_exchange_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,6 @@
@bank = Money::Bank::VariableExchange.new
end

describe '#exchange' do
before :each do
@bank.send(:set_rate, 'USD', 'EUR', 1.33)
end

it 'should accept str/str' do
lambda{@bank.exchange(100, 'USD', 'EUR')}.should_not raise_exception
end

it 'should accept currency/str' do
lambda{@bank.exchange(100, Money::Currency.wrap('USD'), 'EUR')}.should_not raise_exception
end

it 'should accept str/currency' do
lambda{@bank.exchange(100, 'USD', Money::Currency.wrap('EUR'))}.should_not raise_exception
end

it 'should accept currency/currency' do
lambda{@bank.exchange(100, Money::Currency.wrap('USD'), Money::Currency.wrap('EUR'))}.should_not raise_exception
end

it 'should exchange one currency to another' do
@bank.exchange(100, 'USD', 'EUR').should == 133
end

it 'should truncate extra digits' do
@bank.exchange(10, 'USD', 'EUR').should == 13
end

it 'should raise an UnknownCurrency exception when an unknown currency is requested' do
lambda{@bank.exchange(100, 'AAA', 'BBB')}.should raise_exception(Money::Currency::UnknownCurrency)
end

it 'should raise an UnknownRate exception when an unknown rate is requested' do
lambda{@bank.exchange(100, 'USD', 'JPY')}.should raise_exception(Money::Bank::UnknownRate)
end

it 'should round the exchanged result down' do
@bank.add_rate("USD", "EUR", 0.788332676)
@bank.add_rate("EUR", "YEN", 122.631477)
@bank.exchange(10_00, "USD", "EUR").should == 788
@bank.exchange(500_00, "EUR", "YEN").should == 6131573
end

it 'should accept a custom truncation method' do
proc = Proc.new { |n| n.ceil }
@bank.exchange(10, 'USD', 'EUR', &proc).should == 14
end


context 'sterling to euros using a rate of 1.39' do
it 'returns the correct amount' do
@bank.add_rate('GBP', 'EUR', 1.38)
@bank.exchange(10000, 'GBP', 'EUR').should == 13800
end
end

context 'dollars to euros using a rate of 0.86' do
it 'returns the correct amount' do
@bank.add_rate('USD', 'EUR', 0.86)
@bank.exchange(10000, 'USD', 'EUR').should == 8600
end
end

context 'TND to USD using a rate of 0.67138' do
it 'returns the correct amount' do
@bank.add_rate('TND', 'USD', 0.67138)
@bank.exchange(1000, 'TND', 'USD').should == 67
end
end

context 'USD to TND using a rate of 1.32862' do
it 'returns the correct amount' do
@bank.add_rate('USD', 'TND', 1.32862)
@bank.exchange(1000, 'USD', 'TND').should == 13286
end
end
end

describe '#exchange_with' do
before :each do
@bank.send(:set_rate, 'USD', 'EUR', 1.33)
Expand Down Expand Up @@ -286,17 +207,6 @@
@bank.add_rate('USD', 'EUR', 1.33)
end

describe '#exchange' do
it 'should use a stored truncation method' do
@bank.exchange(10, 'USD', 'EUR').should == 14
end

it 'should use a custom truncation method over a stored one' do
proc = Proc.new { |n| n.ceil + 1 }
@bank.exchange(10, 'USD', 'EUR', &proc).should == 15
end
end

describe '#exchange_with' do
it 'should use a stored truncation method' do
@bank.exchange_with(Money.new(10, 'USD'), 'EUR').should == Money.new(14, 'EUR')
Expand Down
12 changes: 0 additions & 12 deletions spec/deprecations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
require "spec_helper"

describe "Money deprecations" do

describe Money::VariableExchangeBank do
it "should be deprecated" do
Money.should_receive(:deprecate)
Money::VariableExchangeBank.new.should_not be_nil
end

it "should extend Money::Bank::VariableExchange" do
Money::VariableExchangeBank.new.should be_kind_of Money::Bank::VariableExchange
end
end

end

0 comments on commit d579d11

Please sign in to comment.