Skip to content

Instantly share code, notes, and snippets.

@alext
Created February 21, 2013 10:51
Show Gist options
  • Save alext/5003890 to your computer and use it in GitHub Desktop.
Save alext/5003890 to your computer and use it in GitHub Desktop.
Field matchers
module FieldMatchers
def i_should_see_field(name, options = {})
field = find_field(name)
field.should_not be_nil
case options[:type]
when nil
when 'textarea'
field.tag_name.should == type
else
field.tag_name.should == 'input'
field['type'].should == options[:type]
end
if options.has_key?(:value)
field.value.should == options[:value]
elsif options.has_key?(:checked)
field['checked'].should == options[:checked]
end
end
end
RSpec.configuration.include FieldMatchers, :type => :feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment