Sha256: dc8836cd121867df994626929e132e45351a42dca822cddf7b53902d92791ac0
Contents?: true
Size: 1.74 KB
Versions: 8
Compression:
Stored size: 1.74 KB
Contents
Given /^there exists form "([^"]*)"(?: of type "([^"]*)")?$/ do |form_name, form_type_name| form_type_name ||= 'My Form Type' Factory :form, :name => form_name, :form_type => Factory(:form_type, :name => form_type_name) end Given /^there exists an? "([^"]*)" "([^"]*)" field "([^"]*)" in "([^"]*)"$/ do |optional_or_required, field_type, field_name, form_name| form = Form.find_by_name(form_name) || Factory( :form, :name => form_name ) form_section = form.form_sections.last || Factory( :form_section, :form => form ) required = optional_or_required == 'required' field_sym = ('form_field_' + field_type.downcase.gsub(/ /, '_')).to_sym #converts field type string to factory symbol Factory field_sym, :name => field_name, :form_section => form_section, :required => required end Given /^there exists an? "([^"]*)" field "([^"]*)" in "([^"]*)" with options "([^"]*)"$/ do |field_type, field_name, form_name, option_list| form = Form.find_by_name(form_name) || Factory( :form, :name => form_name ) form_section = form.form_sections.first || Factory( :form_section, :form => form ) field_sym = ('form_field_' + field_type.downcase.gsub(/ /, '_')).to_sym #converts field type string to factory symbol field = Factory field_sym, :name => field_name, :form_section => form_section option_list.split(',').each do |option| Factory :form_field_option_value, :form_field => field, :value => option.strip end end Then /^the "([^"]*)" field should contain zipcode "([^"]*)"$/ do |label_text, zipcode| label_for = find('label', :text => label_text)[:for] zip1_id = label_for + '_us_zip1' zip2_id = label_for + '_us_zip2' find("##{zip1_id}").value.should == zipcode.split('-')[0] find("##{zip2_id}").value.should == ( zipcode.split('-')[1] || '' ) end
Version data entries
8 entries across 8 versions & 1 rubygems