Skip to content

Commit

Permalink
Improve watir patch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Jun 15, 2015
1 parent 2033489 commit eed49f4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/by_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,13 @@ def by_methods
none = []
expect(difference).to eq(none)
end

it 'repeater inner errors on invalid repeaters' do
# Repeater constructors and setters correctly validate all input
# so the only way to create an invalid repeater is by direct modification
# of the instance variable.
repeater = by.repeater('ok')
repeater.instance_variable_set(:@repeat_descriptor, nil)
expect_error { repeater.process }
end
end
27 changes: 27 additions & 0 deletions spec/watir_patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,31 @@

expect_equal element(by.binding('slowHttpStatus')).exists?, true
end

it 'validate_element' do
selector = browser.input(id: 'testing').locator
locator_class = ::Watir::ElementLocator

locator = locator_class.new(browser, selector, ::Watir::Element.attribute_list)

mock_element = Class.new do
def tag_name
'input'
end

def attribute type
'random'
end
end.new

locator.validate_element mock_element
end

it 'watir::browser' do
browser.instance_variable_set(:@closed, true)
expect_error { browser.assert_exists }

browser.instance_variable_set(:@closed, false)
expect_no_error { browser.assert_exists }
end
end

0 comments on commit eed49f4

Please sign in to comment.