Module: OandaExchange::Stubs
- Defined in:
- lib/oanda_exchange/stubs.rb
Constant Summary collapse
- DEFAULT_CURRENCIES =
{"USD" => "US Dollar", "EUR" => "Euro"}
- DEFAULT_RATES =
{"USD" => 1, "other" => 1.5}
Class Method Summary collapse
Class Method Details
.stub!(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/oanda_exchange/stubs.rb', line 7 def self.stub!( = {}) raise "RSpec stub library required" unless Object.respond_to? :stub! rates = [:rates] || DEFAULT_RATES Oanda.stub!(:exchange) do |cur, opts| BigDecimal.new((opts[:amount] || 0).to_s, 5) * (rates[cur] || rates["other"] || 1) end Oanda.stub!(:currencies).and_return([:currencies] || DEFAULT_CURRENCIES) end |