Module: Briar::Page::Helpers
- Defined in:
- lib/briar/page/briar_page_helpers.rb
Instance Method Summary collapse
-
#cp_is?(page_class, current_page = @cp) ⇒ Boolean
returns
true
ifcurrent_page
is an instance ofpage_class
. -
#expect_current_page(page_class, current_page = @cp) ⇒ Object
raises a exception if the
current_page
is not an instance ofpage_class
. -
#expect_current_page_is_one_of(page_classes, current_page = @cp) ⇒ Object
raises an exception if the
current_page
is not an instance of any ofpage_classes
.
Instance Method Details
#cp_is?(page_class, current_page = @cp) ⇒ Boolean
returns true
if current_page
is an instance of page_class
the current_page
argument defaults to the @cp World variable
8 9 10 |
# File 'lib/briar/page/briar_page_helpers.rb', line 8 def cp_is?(page_class, current_page=@cp) current_page.is_a?(page_class) end |
#expect_current_page(page_class, current_page = @cp) ⇒ Object
raises a exception if the current_page
is not an instance of page_class
the current_page
argument defaults to the @cp World variable
16 17 18 19 20 |
# File 'lib/briar/page/briar_page_helpers.rb', line 16 def expect_current_page(page_class, current_page=@cp) unless cp_is? page_class, current_page screenshot_and_raise "expected current page to be '#{page_class}' but found '#{current_page}'" end end |
#expect_current_page_is_one_of(page_classes, current_page = @cp) ⇒ Object
raises an exception if the current_page
is not an instance of any of page_classes
the current_page
argument defaults to the @cp World variable
26 27 28 29 30 31 |
# File 'lib/briar/page/briar_page_helpers.rb', line 26 def expect_current_page_is_one_of(page_classes, current_page=@cp) res = page_classes.any? { |page_class| cp_is?(page_class, current_page) } unless res screenshot_and_raise "expected current page to be on of these '#{page_classes}' pages but found '#{current_page}'" end end |