Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. thing1: 'thing1'
  2. thing2: 'thing2'
  3. thing3: 'first'
  4. thing3: 'second'
  5. thing4: 'thing4'
  6. thing5: 'thing5'
  7. thing5: 'thing5'
  8. thing6: 'thing6'
  9.  
  10. require 'rspec'
  11.  
  12. describe 'Page Objects locator yml file' do
  13. it 'does not have duplicates' do
  14. file = File.open('locators.yml')
  15. pairs = []
  16. keys = []
  17.  
  18. file.each_line do |line|
  19. words = line.split(': ')
  20. pairs << {words[0] => words[1]}
  21. keys << words[0]
  22. end
  23. file.close
  24.  
  25. if keys.uniq.count != keys.count
  26. p "Duplicate Page Object key(s) found: #{keys.uniq.count} unique vs #{keys.count} total"
  27. p 'dupe keys:'
  28. dupe_keys = keys.select{|n| keys.count(n) > 1}.uniq
  29. dupe_keys.each do |key|
  30. pairs.each do |pair|
  31. p "#{key.to_sym} : #{pair[key]}" if pair[key]
  32. end
  33. end
  34. end
  35.  
  36. expect(keys.uniq.count).to eq keys.count
  37.  
  38. end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement