Jump to content

The ultimate community for Ruby on Rails developers.


Testing custom Form Builder

  • Please log in to reply
1 reply to this topic

#1 ashleybye



  • Members
  • 1 posts

Posted 30 July 2014 - 05:07 PM

I am writing a custom form builder, which I have started programming without any tests. As I'm relatively new to Rails and certainly to RSpec I have no idea where to start with writing tests to do this.


My though process is something along the lines of:


Create view with form for method being tested (I don't want to actually create a physical view, just programatically I think).

Expect correct HTML rendered in view.

Repeat for each configuration option.


How would I go about this properly?


The source to my project can be found here: https://github.com/a...on-form-builder

#2 Ohm



  • Moderators
  • 498 posts
  • LocationCopenhagen

Posted 31 July 2014 - 09:36 PM

Remember that you are more than welcome to look at how other people have tested their form builders!


Try and have a look at simple_form (https://github.com/p...ree/master/test) and write some specs similar to theirs.

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users