Class: Booth::Testing::Support::AssertPartial

Inherits:
Object
  • Object
show all
Includes:
Logging, Calls, Capybara::DSL
Defined in:
lib/booth/testing/support/assert_partial.rb

Instance Method Summary collapse

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/booth/testing/support/assert_partial.rb', line 17

def call
  log { "Looking for view `#{partial}`" }
  content = nil
  begin
    ::Timeout.timeout(Capybara.default_max_wait_time) do
      loop do
        content = page.html.match(%r{<template>([^<]+)</template>})[1].strip
        unless content == partial
          sleep 0.1
          next
        end

        log { "The expected view `#{partial}` was rendered." }
        self.class.asserted_partials << partial
        return
      end
    end
  rescue ::Timeout::Error
    raise "Expected view '#{partial}' but timed out with '#{page.html}'"
  end

  raise "Expected view '#{partial}' but got '#{content}'"
end

#partialObject



41
42
43
# File 'lib/booth/testing/support/assert_partial.rb', line 41

def partial
  "#{namespace}/#{controller}/#{step}"
end