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, resolved = {}, _resolving = []) ⇒ Object
- #get_fixture_values(names, node, spec, context, location, resolved = {}, _resolving = []) ⇒ Object
Instance Method Details
#get_fixture_value(name, node, spec, context, location, resolved = {}, _resolving = []) ⇒ Object
1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 |
# File 'lib/oktest.rb', line 1710 def get_fixture_value(name, node, spec, context, location, resolved={}, _resolving=[]) return resolved[name] if resolved.key?(name) 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}" else args = [] end #; [!gyyst] overwrites keyword params by fixture values. kwnames = Util.keyword_param_names_of_block(block) kwargs = {} kwnames.each {|name| kwargs[name] = resolved[name] if resolved.key?(name) } #; [!4xghy] calls fixture block with context object as self. val = context.instance_exec(*args, **kwargs, &block) #; [!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.to_s]) if location raise exc end end |
#get_fixture_values(names, node, spec, context, location, resolved = {}, _resolving = []) ⇒ Object
1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 |
# File 'lib/oktest.rb', line 1696 def get_fixture_values(names, node, spec, context, location, 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. 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 |