Class: Megatest::State::SharedSuite
- Defined in:
- lib/megatest/state.rb
Instance Attribute Summary
Attributes inherited from Suite
#around_callbacks, #setup_callbacks, #teardown_callbacks
Instance Method Summary collapse
- #included_by(klass_or_module, include_location) ⇒ Object
-
#initialize(registry, test_suite) ⇒ SharedSuite
constructor
A new instance of SharedSuite.
- #register_test_case(name, callable, tags) ⇒ Object
- #shared? ⇒ Boolean
Methods inherited from Suite
#add_tags, #build_test_case, #on_around, #on_setup, #on_teardown, #own_tags, #tag?, #with_context
Constructor Details
#initialize(registry, test_suite) ⇒ SharedSuite
Returns a new instance of SharedSuite.
230 231 232 233 234 235 236 237 238 239 |
# File 'lib/megatest/state.rb', line 230 def initialize(registry, test_suite) super(registry) @klass = test_suite @test_cases = {} test_suite.instance_methods.each do |name| if name.start_with?("test_") register_test_case(name, test_suite.instance_method(name), nil) end end end |
Instance Method Details
#included_by(klass_or_module, include_location) ⇒ Object
245 246 247 248 249 250 251 252 |
# File 'lib/megatest/state.rb', line 245 def included_by(klass_or_module, include_location) if klass_or_module.is_a?(Class) suite = @registry.suite(klass_or_module) @test_cases.each_key do |test_case| suite.include_test_case(test_case, include_location) end end end |
#register_test_case(name, callable, tags) ⇒ Object
254 255 256 257 258 259 260 261 262 263 |
# File 'lib/megatest/state.rb', line 254 def register_test_case(name, callable, ) test = build_test_case(name, callable, , callable.source_location) if @test_cases[test] raise AlreadyDefinedError, "`#{test.id}` already defined at #{Megatest.relative_path(test.source_file)}:#{test.source_line}" end @test_cases[test] = test end |
#shared? ⇒ Boolean
241 242 243 |
# File 'lib/megatest/state.rb', line 241 def shared? true end |