Sha256: c41a90a1775ec308d2be9adf927d80f64363410d53d97a5a4374b289910d0c8d

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

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

  test "'false' returns a boolean" do
    @order.flag = "false"
    assert_equal false, @order.flag
  end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
act_with_bag-1.1.5 test/boolean_test.rb
act_with_bag-1.1.4 test/boolean_test.rb
act_with_bag-1.1.3 test/boolean_test.rb
act_with_bag-1.1.2 test/boolean_test.rb
act_with_bag-1.1.1 test/boolean_test.rb
act_with_bag-1.1.0 test/boolean_test.rb