Sha256: 8487a8138cd40a186a16fbb6c0bd8c67bb7171101bcbe38fb83f0f0f1aa6aad0

Contents?: true

Size: 1.3 KB

Versions: 30

Compression:

Stored size: 1.3 KB

Contents

$TESTING = true

require "composite_sexp_processor"
require "minitest/autorun"

class FakeProcessor1 < SexpProcessor # ZenTest SKIP

  def initialize
    super
    self.warn_on_default = false
    self.default_method = :default_processor
    self.require_empty = false
    self.expected = Array
  end

  def default_processor exp
    t, *rest = exp
    s(t, *rest.map { |s| "#{s} woot" })
  end
end

class TestCompositeSexpProcessor < Minitest::Test

  def setup
    @p = CompositeSexpProcessor.new
  end

  def test_process_default
    data = s(1, 2, 3)
    result = @p.process(data.dup)
    assert_equal(data.dup, result)
  end

  def test_process_fake1
    data = s(:x, 1, 2, 3)
    @p << FakeProcessor1.new
    result = @p.process(data.dup)
    assert_equal [:x, "1 woot", "2 woot", "3 woot"], result
  end

  def test_process_fake1_twice
    data = s(:x, 1, 2, 3)
    @p << FakeProcessor1.new
    @p << FakeProcessor1.new
    result = @p.process(data.dup)
    assert_equal [:x, "1 woot woot", "2 woot woot", "3 woot woot"], result
  end

  def test_processors
    # everything is tested by test_append
    skip
  end

  def test_append
    assert_equal([], @p.processors)

    assert_raises(ArgumentError) do
      @p << 42
    end

    fp1 = FakeProcessor1.new
    @p << fp1
    assert_equal([fp1], @p.processors)
  end

end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
sexp_processor-4.17.3 test/test_composite_sexp_processor.rb
sexp_processor-4.17.2 test/test_composite_sexp_processor.rb
sexp_processor-4.17.1 test/test_composite_sexp_processor.rb
sexp_processor-4.17.0 test/test_composite_sexp_processor.rb
sexp_processor-4.16.1 test/test_composite_sexp_processor.rb
sexp_processor-4.16.0 test/test_composite_sexp_processor.rb
sexp_processor-4.15.3 test/test_composite_sexp_processor.rb
sexp_processor-4.15.2 test/test_composite_sexp_processor.rb
sexp_processor-4.15.1 test/test_composite_sexp_processor.rb
sexp_processor-4.15.0 test/test_composite_sexp_processor.rb
sexp_processor-4.14.1 test/test_composite_sexp_processor.rb
sexp_processor-4.14.0 test/test_composite_sexp_processor.rb
sexp_processor-4.13.0 test/test_composite_sexp_processor.rb
sexp_processor-4.12.1 test/test_composite_sexp_processor.rb
sexp_processor-4.12.0 test/test_composite_sexp_processor.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sexp_processor-4.11.0/test/test_composite_sexp_processor.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sexp_processor-4.11.0/test/test_composite_sexp_processor.rb
sexp_processor-4.11.0 test/test_composite_sexp_processor.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sexp_processor-4.10.1/test/test_composite_sexp_processor.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sexp_processor-4.10.1/test/test_composite_sexp_processor.rb