Skip to content

Commit

Permalink
expose present? explicitly on PageObject to prevent ActiveSupport con…
Browse files Browse the repository at this point in the history
…flict
  • Loading branch information
Stephen Turley authored and Stephen Turley committed Aug 9, 2019
1 parent 850d775 commit 0c590a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/page-object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ def save_screenshot(file_name)
platform.save_screenshot file_name
end

#
# Check if root element exists and is visible
#
def present?
root.present?
end

def self.register_widget(widget_tag, widget_class, base_element_tag)
Widgets.register_widget(widget_tag, widget_class, base_element_tag)
end
Expand Down
13 changes: 13 additions & 0 deletions spec/page-object/page-object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ class Foo; def bar; :bar_called; end; private; def baz; end; end
expect(watir_page_object).not_to respond_to :baz
expect(watir_page_object.bar).to eq :bar_called
end

end

context 'when sent present?' do
let(:element) { double }
it 'should ignore the ActiveSupport implementation' do
# simulate ActiveSupport being mixed in
allow_any_instance_of(Object).to receive(:present?)

expect(element).to receive(:present?)
watir_page_object.instance_variable_set(:@root_element, element)
watir_page_object.present?
end
end
end

Expand Down

0 comments on commit 0c590a5

Please sign in to comment.