28 Feb '14, 6pm

Announcing Formulaic, a simple way to fill forms with Capybara in feature specs

# The main entry point for Formulaic is the `fill_form` method. fill_form( # Symbol representing the name of the class the form represents :dependent, # Pass a hash of attributes to be filled. Works great with # `FactoryGirl.attributes_for(:dependent)`. { # The attribute to set and the value. In this case, Formulaic will # `fill_in` the "Name" input with "My dependent". name: 'My dependent', # If the value of an attribute is a hash, Formulaic will look up # translations for the correct model. This is # `t('simple_form.labels.profile.zip_code')`. profile: { zip_code: '12345' }, # Works with dates, too! date_of_birth: 8.years.ago, # When passed an array, it will `check` each of the elements. ethnicity: [Profile::ETHNICITY_OPTIONS.first], } ) # Formulaic provides a simple way to look up the translation for the # submit helper for your model and action. The default is `:create...

Full article: http://robots.thoughtbot.com/form-filling-is-formulaic

Tweets