Module: SystemTestStepHook
- Defined in:
- lib/system_test_step_hook.rb,
lib/system_test_step_hook/version.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Class Attribute Summary collapse
-
.after_hook ⇒ Object
Returns the value of attribute after_hook.
-
.before_hook ⇒ Object
Returns the value of attribute before_hook.
Class Method Summary collapse
Class Attribute Details
.after_hook ⇒ Object
Returns the value of attribute after_hook.
7 8 9 |
# File 'lib/system_test_step_hook.rb', line 7 def after_hook @after_hook end |
.before_hook ⇒ Object
Returns the value of attribute before_hook.
7 8 9 |
# File 'lib/system_test_step_hook.rb', line 7 def before_hook @before_hook end |
Class Method Details
.after(&block) ⇒ Object
13 14 15 |
# File 'lib/system_test_step_hook.rb', line 13 def after(&block) @after_hook = block end |
.before(&block) ⇒ Object
9 10 11 |
# File 'lib/system_test_step_hook.rb', line 9 def before(&block) @before_hook = block end |
.modify_proc(proc) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/system_test_step_hook.rb', line 17 def modify_proc(proc) buffer = ::Parser::Source::Buffer.new('(string)') buffer.source = proc.source parser = ::Parser::CurrentRuby.new ast = parser.parse(buffer) rewriter = ::Parser::Source::TreeRewriter.new(buffer) ast.children.last.children.each do |child| rewriter.insert_before(child.location.expression, "\nSystemTestStepHook.before_hook.call\n") rewriter.insert_after(child.location.expression, "\nSystemTestStepHook.after_hook.call\n") end modified_code = rewriter.process modified_code.split("\n")[1..-2].join("\n") end |