Class: Oktest::FixtureManager
- Inherits:
-
Object
- Object
- Oktest::FixtureManager
- Defined in:
- lib/oktest.rb
Instance Method Summary collapse
- #get_fixture_value(name, node, spec, context, location = nil, _resolved = {}, _resolving = []) ⇒ Object
- #get_fixture_values(names, node, spec, context, location = nil, _resolved = {}, _resolving = []) ⇒ Object
Instance Method Details
#get_fixture_value(name, node, spec, context, location = nil, _resolved = {}, _resolving = []) ⇒ Object
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 |
# File 'lib/oktest.rb', line 1661 def get_fixture_value(name, node, spec, context, location=nil, _resolved={}, _resolving=[]) return _resolved[name] if _resolved.key?(name) location ||= spec.location tuple = node.get_fixture_block(name) if tuple block, param_names, location = tuple #; [!2esaf] resolves fixture dependencies. if param_names _resolving << name args = get_fixture_values(param_names, node, spec, context, location, _resolved, _resolving) (popped = _resolving.pop) == name or raise "** assertion failed: name=#{name.inspect}, resolvng[-1]=#{popped.inspect}" #; [!4xghy] calls fixture block with context object as self. val = context.instance_exec(*args, &block) else val = context.instance_eval(&block) end #; [!8t3ul] caches fixture value to call fixture block only once per spec. _resolved[name] = val return val elsif node.parent #; [!4chb9] traverses parent topics if fixture not found in current topic. return get_fixture_value(name, node.parent, spec, context, location, _resolved, _resolving) elsif ! node.equal?(THE_GLOBAL_SCOPE) #; [!wt3qk] suports global scope. return get_fixture_value(name, THE_GLOBAL_SCOPE, spec, context, location, _resolved, _resolving) else #; [!nr79z] raises error when fixture not found. exc = FixtureNotFoundError.new("#{name}: fixture not found. (spec: #{spec.desc})") exc.set_backtrace([location]) if location raise exc end end |
#get_fixture_values(names, node, spec, context, location = nil, _resolved = {}, _resolving = []) ⇒ Object
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 |
# File 'lib/oktest.rb', line 1646 def get_fixture_values(names, node, spec, context, location=nil, _resolved={}, _resolving=[]) #; [!w6ffs] resolves 'this_topic' fixture name as target objec of current topic. _resolved[:this_topic] = node.target if !_resolved.key?(:this_topic) && node.topic? #; [!ja2ew] resolves 'this_spec' fixture name as description of current spec. _resolved[:this_spec] = spec.desc if !_resolved.key?(:this_spec) #; [!v587k] resolves fixtures. location ||= spec.location return names.collect {|name| #; [!np4p9] raises error when loop exists in dependency. ! _resolving.include?(name) or raise _looped_dependency_error(name, _resolving, location) get_fixture_value(name, node, spec, context, location, _resolved, _resolving) } end |