Module: Template::Test

Defined in:
lib/template-test.rb,
lib/template-test/version.rb

Defined Under Namespace

Classes: Context

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#html(html, &block) ⇒ Context

Runs the test code in the provided block for the specified rendered HTML.

Examples:

see html_spec

Parameters:

  • html (String)

    the rendered HTML content

  • block (Proc)

    a block with template testing code

Returns:

  • (Context)

    the template test context



102
103
104
105
106
107
# File 'lib/template-test.rb', line 102

def html(html, &block)
  context = Context.new
  context.html = html
  context.instance_eval &block
  context
end

#template(template_path, &block) ⇒ Context

Runs the test code in the provided block for the specified template.

Examples:

see erb_spec.

Parameters:

  • template_path (String)

    the path to the template

  • block (Proc)

    a block with the template testing code

Returns:

  • (Context)

    the template test context



90
91
92
93
94
95
# File 'lib/template-test.rb', line 90

def template(template_path, &block)
  context = Context.new
  context.template_path = template_path
  context.instance_eval &block
  context
end