Class: Test::Unit::Fixture::HookPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/fixture.rb,
lib/test/unit/fixture.rb,
lib/test/unit/fixture.rb

Instance Method Summary collapse

Constructor Details

#initialize(test_case, type, default_options) ⇒ HookPoint

Returns a new instance of HookPoint



71
72
73
74
75
76
# File 'lib/test/unit/fixture.rb', line 71

def initialize(default_options)
  @default_options = default_options
  @before_callbacks = []
  @after_callbacks = []
  @unregistered_callbacks = []
end

Instance Method Details

#after_append_callbacksObject



134
135
136
# File 'lib/test/unit/fixture.rb', line 134

def after_append_callbacks
  @after_append_callbacks - @unregistered_callbacks
end

#after_callbacksObject



111
112
113
# File 'lib/test/unit/fixture.rb', line 111

def after_callbacks
  @after_callbacks - @unregistered_callbacks
end

#after_prepend_callbacksObject



130
131
132
# File 'lib/test/unit/fixture.rb', line 130

def after_prepend_callbacks
  @after_prepend_callbacks - @unregistered_callbacks
end

#before_append_callbacksObject



126
127
128
# File 'lib/test/unit/fixture.rb', line 126

def before_append_callbacks
  @before_append_callbacks - @unregistered_callbacks
end

#before_callbacksObject



107
108
109
# File 'lib/test/unit/fixture.rb', line 107

def before_callbacks
  @before_callbacks - @unregistered_callbacks
end

#before_prepend_callbacksObject



122
123
124
# File 'lib/test/unit/fixture.rb', line 122

def before_prepend_callbacks
  @before_prepend_callbacks - @unregistered_callbacks
end

#register(method_name_or_callback, options = nil) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/test/unit/fixture.rb', line 78

def register(method_name_or_callback, options=nil)
  options ||= {}
  unless valid_register_options?(options)
    message = "must be {:before => :prepend}, " +
      "{:before => :append}, {:after => :prepend} or " +
      "{:after => :append}: #{options.inspect}"
    raise ArgumentError, message
  end

  if options.empty?
    options = @default_options
  end
  before_how = options[:before]
  after_how = options[:after]
  if before_how
    @before_callbacks = add_callback(@before_callbacks,
                                     method_name_or_callback,
                                     before_how)
  else
    @after_callbacks = add_callback(@after_callbacks,
                                    method_name_or_callback,
                                    after_how)
  end
end

#unregister(method_name_or_callback) ⇒ Object



103
104
105
# File 'lib/test/unit/fixture.rb', line 103

def unregister(method_name_or_callback)
  @unregistered_callbacks << method_name_or_callback
end