Class: ViewSpec::Scenario

Inherits:
DSL::Context show all
Includes:
DSL::Controller, DSL::Layout, DSL::Params, DSL::Title
Defined in:
lib/view_spec/scenario.rb

Defined Under Namespace

Classes: NoPreviewError

Instance Method Summary collapse

Methods included from DSL::Controller

#controller

Methods included from DSL::Layout

#layout

Methods included from DSL::Params

#param, #params, #resolve_params

Methods included from DSL::Title

#title

Methods inherited from DSL::Context

#entries, #initialize, lookup_attr, lookup_attrs, type

Constructor Details

This class inherits a constructor from ViewSpec::DSL::Context

Instance Method Details

#nameObject



25
26
27
# File 'lib/view_spec/scenario.rb', line 25

def name
  @subject.to_s
end

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



10
11
12
# File 'lib/view_spec/scenario.rb', line 10

def preview(tpl = nil, &block)
  @preview = tpl || block
end

#render_output(*args, **kwargs) ⇒ Object



21
22
23
# File 'lib/view_spec/scenario.rb', line 21

def render_output(*args, **kwargs)
  render_preview(*args, **kwargs, raw: true)
end

#render_preview(params: {}, assigns: {}, layout: false, raw: false) ⇒ Object



14
15
16
17
18
19
# File 'lib/view_spec/scenario.rb', line 14

def render_preview(params: {}, assigns: {}, layout: false, raw: false)
  assigns[:params] = resolve_params(params).to_h
  html = render(renderable_preview, layout:, assigns:)

  raw ? CGI.unescapeHTML(html) : html
end

#short_identifierObject



29
30
31
# File 'lib/view_spec/scenario.rb', line 29

def short_identifier
  @subject.to_short_identifier
end

#to_paramObject



33
34
35
# File 'lib/view_spec/scenario.rb', line 33

def to_param
  short_identifier
end

#to_partial_pathObject



37
38
39
# File 'lib/view_spec/scenario.rb', line 37

def to_partial_path
  "view_spec/scenario"
end