Hi all
I have a helper that generates HTML for dynamically adding items to a
class. It uses Formtastic for the fields:
module Admin
module CompetitionsHelper
def add_competition_class_link(form_builder)
link_to_function "Add competition class" do |page|
form_builder.semantic_fields_for :competition_classes,
CompetitionClass.new, :child_index => ''NEW_RECORD'' do |p|
html = render(:partial =>
''competition_class_form'', :object
=> p)
page <<
"$(''#competition_classes'').append(''#
{escape_javascript(html)}''.replace(/NEW_RECORD/g, new Date().getTime
()));"
end
end
end
end
end
Now I have a problem with testing this with RSpec. I can mock the
SemanticFormBuilder but that does not really check that the correct
HTML is being added. I also have problems mocking the block which
leaves it unseen by Rcov and 100% coverage is lost.
Does anyone have a good way of testing things like these?
Regards
Erik
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.