Class: Minitest::Tagz::Tagger

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/tagz.rb

Overview

Represents the individual instance of a ‘tag` call It is essentially a state machine that works with the patcher to patch and unpatch Minitest properly

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patchers, owner, pending_tags) ⇒ Tagger

Returns a new instance of Tagger.



109
110
111
112
113
114
# File 'lib/minitest/tagz.rb', line 109

def initialize(patchers, owner, pending_tags)
  @patchers = patchers
  @owner = owner
  @pending_tags = pending_tags.map(&:to_s)
  super()
end

Instance Attribute Details

#ownerObject (readonly)

Returns the value of attribute owner.



107
108
109
# File 'lib/minitest/tagz.rb', line 107

def owner
  @owner
end

#patchersObject (readonly)

Returns the value of attribute patchers.



107
108
109
# File 'lib/minitest/tagz.rb', line 107

def patchers
  @patchers
end

#pending_tagsObject (readonly)

Returns the value of attribute pending_tags.



107
108
109
# File 'lib/minitest/tagz.rb', line 107

def pending_tags
  @pending_tags
end

Instance Method Details

#handle_initial_test_definitionObject



124
125
126
127
128
129
130
# File 'lib/minitest/tagz.rb', line 124

def handle_initial_test_definition
  is_initial = @awaiting_initial_test_definition
  @awaiting_initial_test_definition = false if is_initial
  res = yield
  unpatch_test_definitions if is_initial
  res
end

#patch_test_definitionsObject



116
117
118
# File 'lib/minitest/tagz.rb', line 116

def patch_test_definitions
  @patchers.each {|p| p.patch(self)}
end

#tags_declaredObject



102
103
104
105
# File 'lib/minitest/tagz.rb', line 102

def tags_declared
  patch_test_definitions
  @awaiting_initial_test_definition = true
end

#unpatch_test_definitionsObject



120
121
122
# File 'lib/minitest/tagz.rb', line 120

def unpatch_test_definitions
  @patchers.each(&:unpatch)
end