rubyworks / qed

Quality Ensured Documentation

Home Page:http://rubyworks.github.com/qed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cucumber-like Matchers

opened this issue · comments

QED could benefit from some type of document modifiers scripts that triggered actions according to matching text in the demo document. These could then be used in place of begin/end, setup/teardown hooks. For example, such a document might have:

when /new project/ do
   FileUtils.cp('fixture/project', tmpdir)
   Dir.chdir(tmpdir/'project')
end

Then when ever the phrase "new project" appeared in a description these actions would be taken prior to running the subsequent code. We can also have before/after versions, with occur before and after the subsequent code --though these would be more limited as they would only apply to one code section at a time.

Perhaps we could even further and make it easy to fully augment the demonstrations execution, for instance running bash shell code instead of ruby code on certain indented sections.

This has been implement such that a #When clause triggers a procedure if there is a match in a comment section. #Before and #After variations of this were decided against. #When is equivalent to #Before and one can use a secondary match to handle teardowns if needed.