spec/rents/currency_spec.rb in rents-1.0.5 vs spec/rents/currency_spec.rb in rents-1.0.6

- old
+ new

@@ -15,26 +15,32 @@ integer_value = non_formatted.to_i operator_expected_value = '199900' decimal_value = BigDecimal.new '1999.00' operator_with_cents = '300055' # R$ 3.000,55 decimal_expected_value = BigDecimal.new '1999.00' + expected_float_unit_cents = '100005' + expected_float_decimal_cents = '100050' - # Float values float_with_cents = 1000.55 - float_without_cents = 1000.0 + float_without_cents = 1000.00 + float_unit_cents = 1000.05 + float_decimal_cents = 1000.50 + # Values Converted to operator format non_cents_received = Rents::Currency.get_cents operator_value decimal_converted = Rents::Currency.to_decimal operator_value cents_received = Rents::Currency.get_cents operator_with_cents pt_br_operator_converted = Rents::Currency.to_operator_str pt_br en_us_operator_converted = Rents::Currency.to_operator_str en_us integer_converted = Rents::Currency.to_operator_str integer_value big_decimal_converted = Rents::Currency.to_operator_str decimal_value non_formatted_converted = Rents::Currency.to_operator_str non_formatted non_formatted_with_cents_converted = Rents::Currency.to_operator_str non_formatted_with_cents + float_unit_cents_conv = Rents::Currency.to_operator_str float_unit_cents + float_decimal_cents_conv = Rents::Currency.to_operator_str float_decimal_cents context 'Decimal to Operator' do # Convert PT_BR it 'PT_BR should be convertible' do expect(pt_br_operator_converted).to be_a String @@ -68,9 +74,19 @@ expect(integer_converted).to be_a String expect(integer_converted.index('.')).to be_nil expect(integer_converted.index(',')).to be_nil expect(integer_converted).to be_integer expect(integer_converted).to be_equals operator_expected_value + end + end + + context 'Float to Operator' do + it 'unit cents con must be on Operator format' do + expect(float_unit_cents_conv).to be == expected_float_unit_cents + end + + it 'decimal cents con must be on Operator format' do + expect(float_decimal_cents_conv).to be == expected_float_decimal_cents end end context 'Operator to Decimal' do # Convert from the operator to BigDecimal instance, like rails does/need \ No newline at end of file