Sha256: e4ea6ec15f295af1d2639cc62837c4d64d514f176e0b5a014ceca1679a3c5b76

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

require "test_helper"

describe "range #2" do
  def setup
    reset_order
  end

  it "succeeds specifying just a range" do
    Order.add_to_flags range: 0...0
  end

  it "succeeds specifying just a (same) range with an origin" do
    Order.add_to_flags range: 0..0
    Order.add_to_flags range: 0..0, origin: :dummy
  end

  it "rejects more than one range specification" do
    Order.add_to_flags range: 0..0
    assert_raises(ArgumentError) { Order.add_to_flags range: 1..1 }
  end

  it "succeeds validation (pre specification of range)" do
    Order.add_to_flags range: ..0
    Order.add_to_flags :a
  end

  it "succeeds validation (post specification of range)" do
    Order.add_to_flags :a
    Order.add_to_flags range: ..0
  end

  it "fails validation (pre specification of range)" do
    Order.add_to_flags range: (1..)
    assert_raises(RangeError) { Order.add_to_flags :a }
  end

  it "fails validation (post specification of range)" do
    Order.add_to_flags :b, origin: :hugo
    Order.add_to_flags :a
    assert_raises(RangeError) { Order.add_to_flags range: 1.. }
  end

  it "succeeds validation for two flags (post specification of range)" do
    Order.add_to_flags :a, :b # bits 0 & 1
    Order.add_to_flags range: ..1
  end

  it "rejects validation for two flags (post specification of range)" do
    Order.add_to_flags :a, :b # bits 0 & 1
    # :a (bit 0) triggers an exception on the validation of range
    assert_raises(RangeError) { Order.add_to_flags range: 1.. }
  end

  it "rejects post validation" do
    Order.add_to_flags :a, :b # bits 0 & 1
    # :b (bit 1) triggers an exception on the validation of range
    assert_raises(RangeError) { Order.add_to_flags range: ..0 }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
act_with_flags-3.1.9 test/range2_test.rb
act_with_flags-3.1.6 test/range2_test.rb
act_with_flags-3.1.5 test/range2_test.rb
act_with_flags-3.1.3 test/range2_test.rb
act_with_flags-3.1.2 test/range2_test.rb
act_with_flags-3.1.1 test/range2_test.rb