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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to