ChunkMatch (Module)

In: app/models/chunks/match.rb

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.

Methods

match  

Public Instance methods

Asserts a number of tests for the given type and text.

[Source]

    # File app/models/chunks/match.rb, line 7
 7:   def match(type, test_text, expected)
 8:         pattern = type.pattern
 9:     assert_match(pattern, test_text)
10:     pattern =~ test_text   # Previous assertion guarantees match

11:     chunk = type.new($~)
12:     
13:     # Test if requested parts are correct.

14:     for method_sym, value in expected do
15:       assert_respond_to(chunk, method_sym)
16:       assert_equal(value, chunk.method(method_sym).call, "Checking value of '#{method_sym}'")
17:     end
18:   end
19: end

[Validate]