Guest User

Untitled

a guest
Jun 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. test "that rate with same from- and to-rate is invalid" do
  2. rate = ExchangeRate.new
  3. rate.name = "From To Same"
  4. euro = Currency.new
  5. rate.from_currency = euro
  6. rate.to_currency = euro
  7.  
  8. assert rate.from_currency == rate.to_currency
  9.  
  10. assert !rate.valid?
  11. end
  12.  
  13.  
  14. Message:
  15.  
  16. 1) Failure:
  17. test_that_rate_with_same_from-_and_to-rate_is_invalid(ExchangeRateTest) [/test/unit/exchange_rate_test.rb:25]:
  18. <false> is not true.
  19.  
  20. exchange_rate.rb:
  21.  
  22. class ExchangeRate < ActiveRecord::Base
  23.  
  24. validates_presence_of :name, :from_currency, :to_currency
  25. validates_difference_of :from_currency, :to_currency
  26.  
  27. has_many :quotes, :as => :object_with_quotes
  28.  
  29. has_one :latest_quote, :as => :object_with_quotes, :class_name => 'Quote',
  30. :order => "datetime DESC", :readonly => true
  31.  
  32. belongs_to :from_currency, :class_name => "Currency"
  33. belongs_to :to_currency, :class_name => "Currency"
  34. end
Add Comment
Please, Sign In to add comment