Sha256: bbab33223e970b222adebab4adc6b13e9d0886ef082062b6e9aebcf8d2a6f28c

Contents?: true

Size: 1.72 KB

Versions: 29

Compression:

Stored size: 1.72 KB

Contents

require 'test_helper'

class SetTest < MiniTest::Test
  def setup
    @items = ActiveScaffold::DataStructures::Set.new(:a, :b)
  end

  def test_initialization
    assert @items.include?(:a)
    assert @items.include?(:b)
    refute @items.include?(:c)
  end

  def test_exclude
    # exclude with a symbol
    assert @items.include?(:b)
    @items.exclude :b
    refute @items.include?(:b)

    # exclude with a string
    assert @items.include?(:a)
    @items.exclude 'a'
    refute @items.include?(:a)
  end

  def test_exclude_array
    # exclude with a symbol
    assert @items.include?(:b)
    @items.exclude %i[a b]
    refute @items.include?(:b)
    refute @items.include?(:a)
  end

  def test_remove
    assert @items.include?(:a)
    @items.remove 'a'
    refute @items.include?(:a)
  end

  def test_add
    # try adding a simple column using a string
    refute @items.include?(:c)
    @items.add 'c'
    assert @items.include?(:c)

    # try adding a simple column using a symbol
    refute @items.include?(:d)
    @items.add :d
    assert @items.include?(:d)

    # test that << also adds
    refute @items.include?(:e)
    @items << 'e'
    assert @items.include?(:e)

    # try adding an array of columns
    refute @items.include?(:f)
    @items.add %i[f g]
    assert @items.include?(:f)
    assert @items.include?(:g)
  end

  def test_length
    assert_equal 2, @items.length
  end

  def test_block_config
    @items.configure do |config|
      # we may use the config argument
      config.add :c
      # or we may not
      exclude :b
    end

    assert @items.include?(:c)
    refute @items.include?(:b)
  end

  def test_include
    assert @items.include?(:a)
    assert @items.include?(:b)
    refute @items.include?(:d)
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
active_scaffold-3.6.20 test/data_structures/set_test.rb
active_scaffold-3.6.19 test/data_structures/set_test.rb
active_scaffold-3.6.17 test/data_structures/set_test.rb
active_scaffold-3.6.15 test/data_structures/set_test.rb
active_scaffold-3.6.14 test/data_structures/set_test.rb
active_scaffold-3.6.13 test/data_structures/set_test.rb
active_scaffold-3.6.12 test/data_structures/set_test.rb
active_scaffold-3.6.11.1 test/data_structures/set_test.rb
active_scaffold-3.6.11 test/data_structures/set_test.rb
active_scaffold-3.6.10 test/data_structures/set_test.rb
active_scaffold-3.6.9 test/data_structures/set_test.rb
active_scaffold-3.6.8 test/data_structures/set_test.rb
active_scaffold-3.6.6 test/data_structures/set_test.rb
active_scaffold-3.6.5 test/data_structures/set_test.rb
active_scaffold-3.6.4.1 test/data_structures/set_test.rb
active_scaffold-3.6.4 test/data_structures/set_test.rb
active_scaffold-3.6.3 test/data_structures/set_test.rb
active_scaffold-3.6.2 test/data_structures/set_test.rb
active_scaffold-3.6.1 test/data_structures/set_test.rb
active_scaffold-3.6.0 test/data_structures/set_test.rb