Class: AktionTest::Matchers::FileSystem::FileContains::Matcher

Inherits:
Base
  • Object
show all
Defined in:
lib/aktion_test/matchers/file_system/file_contains.rb

Instance Method Summary collapse

Methods inherited from Base

#failure_message, #matches?, #negative_failure_message

Constructor Details

#initialize(lines, options = {}) ⇒ Matcher

Returns a new instance of Matcher.



10
11
12
13
14
15
16
17
18
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 10

def initialize(lines, options={})
  @original_lines = lines
  @lines, @options = init_lines(lines), options
  @options[:match_method] = :all
  allow_any    if @options.delete(:allow_any)
  sequentially if @options.delete(:sequentially)
  @options[:after]  = regexp(@options[:after])  unless @options[:after].nil?
  @options[:before] = regexp(@options[:before]) unless @options[:before].nil?
end

Instance Method Details

#after(match_after) ⇒ Object



29
30
31
32
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 29

def after(match_after)
  @options[:after] = regexp(match_after)
  self
end

#allow_anyObject



24
25
26
27
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 24

def allow_any
  @options[:match_method] = :any
  self
end

#before(match_before) ⇒ Object



34
35
36
37
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 34

def before(match_before)
  @options[:before] = regexp(match_before)
  self
end

#init_lines(lines) ⇒ Object



20
21
22
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 20

def init_lines(lines)
  lines.map { |line| regexp(line) }.flatten
end

#sequentiallyObject



39
40
41
42
# File 'lib/aktion_test/matchers/file_system/file_contains.rb', line 39

def sequentially
  @options[:match_method] = :sequence
  self
end