Module: PartialTestHelpers

Defined in:
lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb

Instance Method Summary collapse

Instance Method Details

#parse(html) ⇒ Object



20
21
22
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 20

def parse(html)
  Nokogiri::HTML(html)
end

#parse_html(selector, single_return: true, render_args: [], html: render_partial(*render_args)) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 24

def parse_html(selector, single_return: true,
                         render_args: [],
                         html: render_partial(*render_args))
  method = single_return ? :at_css : :css

  parse(html).send(method, selector)
end

#partial(*args, **options) ⇒ Object



12
13
14
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 12

def partial(*args, **options)
  partial_for(described_class, *args, **options)
end

#partial_for(klass, *args) ⇒ Object



9
10
11
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 9

def partial_for(klass, *args)
  klass.new(renderer, *args)
end

#render_partial(*args, &block) ⇒ Object



16
17
18
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 16

def render_partial(*args, &block)
  partial.(*args, &block)
end

#rendererObject



5
6
7
# File 'lib/generators/templet/templates/core/spec/support/shared/partial_test_helpers.rb', line 5

def renderer
  Templet::Renderer.new helper
end