Guest User

Untitled

a guest
May 23rd, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. RSpec::Matchers.define :have_country do |expected|
  2. match do |actual|
  3. # usage:
  4. # field_labeled('Select your address').should have_option("Home Address")
  5. RSpec::Matchers.define :have_option do |expected|
  6. def options_for(select_field)
  7. select_field.all('option').map &:text
  8. end
  9.  
  10. match do |select_field|
  11. select_field.has_selector?('option', :text => expected)
  12. end
  13.  
  14. failure_message_for_should do |actual|
  15. "Expected this select field to have the following option: '#{expected}'. Actual options: #{options_for(actual).inspect}"
  16. end
  17.  
  18. failure_message_for_should_not do |actual|
  19. "Expected the select field not to have the following option: '#{expected}'. It did!"
  20. end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment