Sha256: 69fb9fb138eddda221f04594ad9865bf9fa7bb77bf512e5e7b8dcaabeebe22ed

Contents?: true

Size: 1.8 KB

Versions: 221

Compression:

Stored size: 1.8 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')
# require 'test/model_stub'

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

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

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

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

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

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

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

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

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

    # try adding an array of columns
    assert !@items.include?(:f)
    @items.add [: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)
    assert !@items.include?(:b)
  end

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

Version data entries

221 entries across 221 versions & 8 rubygems

Version Path
active_scaffold_vho-4.0.0 test/data_structures/set_test.rb
active_scaffold_vho-3.2.14 test/data_structures/set_test.rb
active_scaffold_vho-3.2.13 test/data_structures/set_test.rb
active_scaffold-sequel-0.8.0 test/data_structures/set_test.rb
active_scaffold-sequel-0.7.1 test/data_structures/set_test.rb
active_scaffold_vho-3.2.12 test/data_structures/set_test.rb
active_scaffold_vho-3.2.11 test/data_structures/set_test.rb
active_scaffold_vho-3.2.10 test/data_structures/set_test.rb
active_scaffold_vho-3.2.9 test/data_structures/set_test.rb
active_scaffold_vho-3.2.8 test/data_structures/set_test.rb
active_scaffold_vho-3.2.7 test/data_structures/set_test.rb
active_scaffold_vho-3.2.6 test/data_structures/set_test.rb
active_scaffold_vho-3.2.5 test/data_structures/set_test.rb
active_scaffold_vho-3.2.4 test/data_structures/set_test.rb
active_scaffold_vho-3.2.3 test/data_structures/set_test.rb
active_scaffold_vho-3.2.2 test/data_structures/set_test.rb
active_scaffold_vho-3.2.1 test/data_structures/set_test.rb
active_scaffold-sequel-0.7.0 test/data_structures/set_test.rb
active_scaffold_vho-3.2.0 test/data_structures/set_test.rb
active_scaffold_vho-3.0.31 test/data_structures/set_test.rb