Class: Smartest::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/smartest/suite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSuite

Returns a new instance of Suite.



7
8
9
10
11
12
13
14
15
# File 'lib/smartest/suite.rb', line 7

def initialize
  @tests = TestRegistry.new
  @fixture_classes = FixtureClassRegistry.new
  @matcher_modules = MatcherRegistry.new
  @around_suite_hooks = []
  @around_test_hooks = []
  @around_test_hooks_by_file = Hash.new { |hash, path| hash[path] = [] }
  @around_suite_hook_depth = 0
end

Instance Attribute Details

#around_suite_hooksObject (readonly)

Returns the value of attribute around_suite_hooks.



5
6
7
# File 'lib/smartest/suite.rb', line 5

def around_suite_hooks
  @around_suite_hooks
end

#around_test_hooksObject (readonly)

Returns the value of attribute around_test_hooks.



5
6
7
# File 'lib/smartest/suite.rb', line 5

def around_test_hooks
  @around_test_hooks
end

#fixture_classesObject (readonly)

Returns the value of attribute fixture_classes.



5
6
7
# File 'lib/smartest/suite.rb', line 5

def fixture_classes
  @fixture_classes
end

#matcher_modulesObject (readonly)

Returns the value of attribute matcher_modules.



5
6
7
# File 'lib/smartest/suite.rb', line 5

def matcher_modules
  @matcher_modules
end

#testsObject (readonly)

Returns the value of attribute tests.



5
6
7
# File 'lib/smartest/suite.rb', line 5

def tests
  @tests
end

Instance Method Details

#add_around_test_hook(location, hook) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/smartest/suite.rb', line 17

def add_around_test_hook(location, hook)
  if running_around_suite_hook?
    @around_test_hooks << hook
  else
    @around_test_hooks_by_file[path_for(location)] << hook
  end
end

#around_suite_hookObject



29
30
31
32
33
34
# File 'lib/smartest/suite.rb', line 29

def around_suite_hook
  @around_suite_hook_depth += 1
  yield
ensure
  @around_suite_hook_depth -= 1
end

#around_test_hooks_for(location) ⇒ Object



25
26
27
# File 'lib/smartest/suite.rb', line 25

def around_test_hooks_for(location)
  @around_test_hooks_by_file[path_for(location)].dup
end