Created
October 10, 2011 13:58
-
-
Save supaspoida/1275392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define :have_country do |expected| | |
match do |actual| | |
# usage: | |
# field_labeled('Select your address').should have_option("Home Address") | |
RSpec::Matchers.define :have_option do |expected| | |
def options_for(select_field) | |
select_field.all('option').map &:text | |
end | |
match do |select_field| | |
select_field.has_selector?('option', :text => expected) | |
end | |
failure_message_for_should do |actual| | |
"Expected this select field to have the following option: '#{expected}'. Actual options: #{options_for(actual).inspect}" | |
end | |
failure_message_for_should_not do |actual| | |
"Expected the select field not to have the following option: '#{expected}'. It did!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment