Class: Booth::Testing::Support::AssertPartial
- Inherits:
-
Object
- Object
- Booth::Testing::Support::AssertPartial
- Includes:
- Logging, Calls, Capybara::DSL
- Defined in:
- lib/booth/testing/support/assert_partial.rb
Instance Method Summary collapse
- #actual_tag ⇒ Object
- #call ⇒ Object
- #expected_tag ⇒ Object
- #partial ⇒ Object
- #test_file_and_line_number ⇒ Object
Instance Method Details
#actual_tag ⇒ Object
36 37 38 39 |
# File 'lib/booth/testing/support/assert_partial.rb', line 36 def actual_tag page.html.scan(%r{<template>[^/]+/[^/]+/[^/]+</template>}).uniq.first.presence || page.text end |
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/booth/testing/support/assert_partial.rb', line 17 def call ::::Lockstep.synchronize log { "Looking for view `#{partial}`" } assert_selector 'template', visible: false content = page.html.match(%r{<template>([^<]+)</template>})[1].strip raise "Expected view '#{partial}' but got '#{content}'" unless content == partial log { "The expected view `#{partial}` was rendered." } self.class.asserted_partials << partial nil end |
#expected_tag ⇒ Object
32 33 34 |
# File 'lib/booth/testing/support/assert_partial.rb', line 32 def expected_tag "<template>#{partial}</template>" end |
#partial ⇒ Object
41 42 43 |
# File 'lib/booth/testing/support/assert_partial.rb', line 41 def partial "#{namespace}/#{controller}/#{step}" end |
#test_file_and_line_number ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/booth/testing/support/assert_partial.rb', line 45 def test_file_and_line_number # Called from e.g. `::Booth::Testing::Userland::LoginRemotely`. candidate = caller[3].split(':in ').first return candidate unless candidate.include?('calls') # Called from e.g. `::Booth::Testing::Support::RegisterNewPasskey`. caller[2].split(':in ').first end |