Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thing1: 'thing1'
- thing2: 'thing2'
- thing3: 'first'
- thing3: 'second'
- thing4: 'thing4'
- thing5: 'thing5'
- thing5: 'thing5'
- thing6: 'thing6'
- require 'rspec'
- describe 'Page Objects locator yml file' do
- it 'does not have duplicates' do
- file = File.open('locators.yml')
- pairs = []
- keys = []
- file.each_line do |line|
- words = line.split(': ')
- pairs << {words[0] => words[1]}
- keys << words[0]
- end
- file.close
- if keys.uniq.count != keys.count
- p "Duplicate Page Object key(s) found: #{keys.uniq.count} unique vs #{keys.count} total"
- p 'dupe keys:'
- dupe_keys = keys.select{|n| keys.count(n) > 1}.uniq
- dupe_keys.each do |key|
- pairs.each do |pair|
- p "#{key.to_sym} : #{pair[key]}" if pair[key]
- end
- end
- end
- expect(keys.uniq.count).to eq keys.count
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement