Sha256: ec3baa1e3af9f7c617634f3f5b3f8bb61407aa49d6fe82ea298eacb58d3d10f3

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/exacto.rb
#
# Extracted Fri Feb 23 00:03:20 EST 2007
# Project.rb Test Extraction
#

require 'exacto.rb'


  require 'test/unit'

  class ExactoTest < Test::Unit::TestCase

    def exacto_knife
      @knife ||= Exacto.new('/dev/null')
    end

    def build_pattern_block(block, code)
      exacto_knife.pattern_block(block).match(code)
    end

    # Usual case.

    def test_pattern_block
      assert_equal "require 'foo'\nfoo", build_pattern_block('test', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
    end

    # Some tests for when the block is empty ('') -- should it act as a wildcard and match *any* block,
    # or should Exacto::Command#initialize complain about that.

    def test_pattern_block_no_handle
      assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin\nrequire 'foo'\nfoo\n=end")[1]
    end

    def test_pattern_block_no_handle_given
      assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
    end

    # Yes, I know, as a side-effect of this regexp change, it will also match some invalid "blocks", like =beginblah. But that
    # seems like a nonissue, given that the Ruby parser would reject that syntax anyway.

    def test_pattern_block_side_effects
      assert_equal "require 'foo'\nfoo", build_pattern_block('', "=beginblah\nrequire 'foo'\nfoo\n=end")[1]
    end

  end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proutils-0.3.0 test/lib/test_exacto.rb
proutils-0.3.1 test/lib/test_exacto.rb