Sha256: 6ccd2af6ca5d39b0a29bcaf41406984968ccd4299091908f4f3b63ea319229a9

Contents?: true

Size: 753 Bytes

Versions: 5

Compression:

Stored size: 753 Bytes

Contents

# This module is to be included in unit tests that involve matching chunks.
# It provides a easy way to test whether a chunk matches a particular string
# and any the values of any fields that should be set after a match.
module ChunkMatch

  # Asserts a number of tests for the given type and text.
  def match(type, test_text, expected)
	pattern = type.pattern
    assert_match(pattern, test_text)
    pattern =~ test_text   # Previous assertion guarantees match
    chunk = type.new($~)
    
    # Test if requested parts are correct.
    for method_sym, value in expected do
      assert_respond_to(chunk, method_sym)
      assert_equal(value, chunk.method(method_sym).call, "Checking value of '#{method_sym}'")
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
Pimki-1.0.092 app/models/chunks/match.rb
Pimki-1.1.092 app/models/chunks/match.rb
Pimki-1.2.092 app/models/chunks/match.rb
Pimki-1.3.092 app/models/chunks/match.rb
instiki-0.9.2 app/models/chunks/match.rb