Sha256: 316f584dc1901d6188136a1220bedec8365a41df8841144ad7494704788378a8

Contents?: true

Size: 880 Bytes

Versions: 43

Compression:

Stored size: 880 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..'))

require 'test/unit'
require 'rex/exceptions'
require 'rex/transformer'

class Rex::Transformer::UnitTest < Test::Unit::TestCase
	class Pizza
		def Pizza.from_s(str)
		end
	end

	class ArrayTester
		def self.from_a(a)
			a[0] + a[1]
		end
	end

	def test_transformer
		a = Rex::Transformer.transform([ 'yo', 'ho' ], Array, [ String ], 'Jones')

		assert_equal(2, a.length, "invalid array length")
		assert_equal('yo', a[0], "invalid first element")
		assert_equal('ho', a[1], "invalid second element")

		assert_raise(Rex::ArgumentError, "invalid transform") {
			Rex::Transformer.transform('dog', Array, [ Pizza ], 'bob')
		}
	end

	def test_from_a
		a = Rex::Transformer.transform([ [ 'one', 'two' ] ], Array, [ ArrayTester ], 'Jimmy')

		assert_equal('onetwo', a[0], "invalid from_a conversion")
	end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/transformer.rb.ut.rb
librex-0.0.63 lib/rex/transformer.rb.ut.rb
librex-0.0.54 lib/rex/transformer.rb.ut.rb
librex-0.0.53 lib/rex/transformer.rb.ut.rb
librex-0.0.52 lib/rex/transformer.rb.ut.rb
librex-0.0.51 lib/rex/transformer.rb.ut.rb
librex-0.0.50 lib/rex/transformer.rb.ut.rb
librex-0.0.49 lib/rex/transformer.rb.ut.rb
librex-0.0.48 lib/rex/transformer.rb.ut.rb
librex-0.0.47 lib/rex/transformer.rb.ut.rb
librex-0.0.46 lib/rex/transformer.rb.ut.rb
librex-0.0.44 lib/rex/transformer.rb.ut.rb
librex-0.0.43 lib/rex/transformer.rb.ut.rb
librex-0.0.42 lib/rex/transformer.rb.ut.rb
librex-0.0.41 lib/rex/transformer.rb.ut.rb
librex-0.0.40 lib/rex/transformer.rb.ut.rb
librex-0.0.39 lib/rex/transformer.rb.ut.rb
librex-0.0.38 lib/rex/transformer.rb.ut.rb
librex-0.0.37 lib/rex/transformer.rb.ut.rb
librex-0.0.36 lib/rex/transformer.rb.ut.rb