Module: ViewSpec::DSL::Preview

Extended by:
ActiveSupport::Concern
Included in:
ScenarioContext
Defined in:
lib/view_spec/dsl/preview.rb

Instance Method Summary collapse

Instance Method Details

#preview(tpl = nil, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/view_spec/dsl/preview.rb', line 6

def preview(tpl = nil, &block)
  return @preview if tpl.nil? && !block_given?

  @preview = if block
    ExecutableProc.new(block)
  elsif tpl.is_a?(String)
    ExecutableString.new(tpl, caller_lang(caller_locations(1..1)&.first, :erb))
  else
    raise "Invalid preview argument (must be string or block)"
  end
end