Sha256: b8a237442079ae0b1c5625f75b98f9470558272ae2296265992db09f46dfd8b3

Contents?: true

Size: 1.33 KB

Versions: 23

Compression:

Stored size: 1.33 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.expected = Array
  end

  def default_processor(exp)
    result = []
    result << exp.shift
    until exp.empty? do
      result << exp.shift.to_s + " woot"
    end
    result
  end
end

class TestCompositeSexpProcessor < Minitest::Test

  def setup
    @p = CompositeSexpProcessor.new
  end

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

  def test_process_fake1
    data = [: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 = [: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

23 entries across 23 versions & 4 rubygems

Version Path
brakeman-3.7.0 bundle/ruby/2.3.0/gems/sexp_processor-4.9.0/test/test_composite_sexp_processor.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/sexp_processor-4.9.0/test/test_composite_sexp_processor.rb
sexp_processor-4.9.0 test/test_composite_sexp_processor.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/sexp_processor-4.8.0/test/test_composite_sexp_processor.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/sexp_processor-4.8.0/test/test_composite_sexp_processor.rb
sexp_processor-4.8.0 test/test_composite_sexp_processor.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.4.1 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.4.0 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.5 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.4 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.3 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.2 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.1 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
brakeman-3.3.0 bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sexp_processor-4.7.0/test/test_composite_sexp_processor.rb
sexp_processor-4.7.0 test/test_composite_sexp_processor.rb
sexp_processor-4.6.1 test/test_composite_sexp_processor.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sexp_processor-4.6.0/test/test_composite_sexp_processor.rb
sexp_processor-4.6.0 test/test_composite_sexp_processor.rb