Improve apend_to_publisher
- Use custom matcher that polls #value of the element - Wait for the text field to become visible before entering text
This commit is contained in:
parent
7e4504edf2
commit
1c7e5b7026
2 changed files with 27 additions and 8 deletions
|
|
@ -1,11 +1,6 @@
|
|||
RSpec::Matchers.define :have_path do |expected|
|
||||
match do |actual|
|
||||
start_time = Time.now
|
||||
until actual.current_path == expected
|
||||
return false if (Time.now-start_time) > Capybara.default_wait_time
|
||||
sleep 0.05
|
||||
end
|
||||
true
|
||||
await_condition { actual.current_path == expected }
|
||||
end
|
||||
|
||||
failure_message_for_should do |actual|
|
||||
|
|
@ -15,3 +10,27 @@ RSpec::Matchers.define :have_path do |expected|
|
|||
"expected #{actual.inspect} to not have path #{expected.inspect} but it had"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
RSpec::Matchers.define :have_value do |expected|
|
||||
match do |actual|
|
||||
await_condition { actual.value && actual.value.include?(expected) }
|
||||
end
|
||||
|
||||
failure_message_for_should do |actual|
|
||||
"expected #{actual.inspect} to have value #{expected.inspect} but was #{actual.value.inspect}"
|
||||
end
|
||||
failure_message_for_should_not do |actual|
|
||||
"expected #{actual.inspect} to not have value #{expected.inspect} but it had"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def await_condition &condition
|
||||
start_time = Time.now
|
||||
until condition.call
|
||||
return false if (Time.now-start_time) > Capybara.default_wait_time
|
||||
sleep 0.05
|
||||
end
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ module PublishingCukeHelpers
|
|||
end
|
||||
|
||||
def append_to_publisher(txt, input_selector='#status_message_fake_text')
|
||||
elem = find(input_selector, visible: false)
|
||||
elem = find(input_selector)
|
||||
elem.native.send_keys(' ' + txt)
|
||||
|
||||
# make sure the other text field got the new contents
|
||||
expect(page).to have_xpath("//input|textarea/.[@id='status_message_text' and contains(@value, '#{txt}')]", visible: false)
|
||||
expect(find("#status_message_text", visible: false)).to have_value txt
|
||||
end
|
||||
|
||||
def upload_file_with_publisher(path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue