Reputation: 3651
I have a problem with rspec and page object. I have
cell(:balance_type_tab_element, :id => 'a')
and then later down the line I have
def check_all
check_navigation_to_and_from_balance_page
check_printer_friendly_link
end
and then i also have
def check_allocation_by_balance_type
balance_type_tab?
puts "found tab"
puts balance_type_tab_element.visible?
balance_type_tab_element.visible?.should be_true
end
and
def check_navigation_to_and_from_balance_page
//some other checks
check_allocation_by_balance_type
end
then in a steps file
on_page(ParticipantBalanceDetailsPage).check_all
but i keep getting the error NameError: undefined local variable or method `be_true'
I tried googling but no luck so far, can someone help me out please?
Upvotes: 2
Views: 558
Reputation: 21810
The various matcher methods are not automatically available in every context. Consider that when you call be_true
, you are sending the be_true
message to self
. To make all matchers available in every context, RSpec would have to add ALL of the matcher objects to EVERY object in the system, which would be a terrible idea.
To make the matchers available in this context, you simply need to mix RSpec::Matchers
in to your class:
class MyPageObject
include RSpec::Matchers
def check_allocation_by_balance_type
balance_type_tab?
puts "found tab"
puts balance_type_tab_element.visible?
balance_type_tab_element.visible?.should be_true
end
end
Upvotes: 6