testing - Test lengthy form without re-writing all the fill_ins everytime -
testing - Test lengthy form without re-writing all the fill_ins everytime -
i have long form, , 3 of fields, need test whether filled out right or wrong individually, because errors lead different actions. it's tedious , not dry write integration tests this:
# test 1 describe "test field3 fails" before fill_in "field1", with: "passing info" fill_in "field2", with: "passing info" fill_in "field3", with: "not passing info" ... end "should lead error specific field3" ... end end # test 2 describe "test field2 fails" before fill_in "field1", with: "passing info" fill_in "field2", with: "not passing info" fill_in "field3", with: "passing info" ... end "should lead error specific field2" ... end end # test 3 describe "test field1 fails" before fill_in "field1", with: "not passing info" fill_in "field2", with: "passing info" fill_in "field3", with: "passing info" ... end "should lead error specific field1" ... end end
in case ,i suggest write info driven tests below
describe "test form fields" |data| before fill_in "field1", with: data[0] fill_in "field2", with: data[1] fill_in "field3", with: data[2] ... end "should lead error message" |correspondingerrormsg| ... end
this way combinations defined within test info ,not in code in future if no. of validations increment or decrease don't have touch code.only data. hope makes sense create solution dry.
testing ruby-on-rails-4 rspec capybara integration-testing
Comments
Post a Comment