Sha256: 926e20b03d7914cd4cea0579c089a441999586ebb5c880cd17c76c001d4ac43d

Contents?: true

Size: 852 Bytes

Versions: 5

Compression:

Stored size: 852 Bytes

Contents

require "test_helper"

class A < Order
end

class B < Order
  include ActWithBooleans

  add_to_booleans y: 2
end

describe "inheritance" do
  let(:order) { Order.new }
  let(:a) { A.new }
  let(:b) { B.new }

  def setup
    reset_order
    Order.add_to_booleans x: 1
  end

  it "tests Order" do
    refute order.x?
    order.x = true
    assert order.x?
  end

  it "tests A" do
    refute a.x?
    a.x = true
    assert a.x?
  end

  it "tests B" do
    refute b.x?
    b.x = true
    assert b.x?

    refute b.y?
    b.y = true
    assert b.y?

    assert_raises { order.y? }
  end

  it "tests booleans_mask" do
    assert_equal 0x02, Order.booleans_mask(:x)
    assert_raises { Order.booleans_mask(:y) }
    assert_raises { B.booleans_mask(:x) }
    assert_equal 0x04, B.booleans_mask(:y)
    assert_raises { B.booleans_mask(:x, :y) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
act_with_booleans-0.0.5 test/inheritance_test.rb
act_with_booleans-0.0.4 test/inheritance_test.rb
act_with_booleans-0.0.3 test/inheritance_test.rb
act_with_booleans-0.0.2 test/inheritance_test.rb
act_with_booleans-0.0.1 test/inheritance_test.rb