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
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 |
# File 'lib/oktest.rb', line 1360 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
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
# File 'lib/oktest.rb', line 1345 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 |