Sha256: aff393dba5e1489fd1ffd6aa29f384a9d45e30643224d798c54ec52bae1e2b7c

Contents?: true

Size: 1016 Bytes

Versions: 5

Compression:

Stored size: 1016 Bytes

Contents

require 'test_helper'

class BooleanTest < ActiveSupport::TestCase

  def setup
    @order = Order.new
  end

  test "boolean access to flag" do
    value = true
    @order.flag = value
    assert_equal value, @order.flag
    assert @order.flag?
    assert_not_equal false, @order.flag

    value = false
    @order.flag = value
    assert_equal value, @order.flag
    assert !@order.flag?
    assert_not_equal true, @order.flag
  end

  test "boolean returns a boolean" do
    value = true
    @order.flag = value
    assert_equal true, @order.flag

    value = false
    @order.flag = value
    assert_equal false, @order.flag
  end

  test "1/0 returns a boolean" do
    @order.flag = 1
    assert_equal true, @order.flag

    @order.flag = 0
    assert_equal false, @order.flag
  end

  test "string 1/0 returns a boolean" do
    @order.flag = '1'
    assert_equal true, @order.flag

    @order.flag = '0'
    assert_equal false, @order.flag

    @order.flag = nil
    assert_equal false, @order.flag
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
act_with_bag-0.4.9.1 test/boolean_test.rb
act_with_bag-0.4.9 test/boolean_test.rb
act_with_bag-0.4.7 test/boolean_test.rb
act_with_bag-0.4.4 test/boolean_test.rb
act_with_bag-0.4.2 test/boolean_test.rb