olivernn / poirot

mustaches in your rails
http://olivernn.github.com/poirot
108 stars 21 forks source link

Problem with parameterize in cucumber/selenium #23

Open clemenshelm opened 12 years ago

clemenshelm commented 12 years ago

When I run cucumber/selenium the execution gets stuck when template_include_tag is called. After playing around with it, I realized that the parameterize call causes this error.

I came up with a patch for the whole method (because also the template file wouldn't get closed):

module Poirot
  module AssetHelper
    def template_include_tag(*sources)
      sources.collect do |source|
        template = File.read(resolve_partial_path(source))
        template_name = source.to_s.split('/').last.dasherize
        content_tag :script, template.html_safe, :type => "text/mustache", :id => "#{template_name}-template"
      end.join("\n").html_safe
    end
  end
end

This works perfectly for me and even the template_name method is obsolete. Is there a case where parameterize is really necessary?

olivernn commented 12 years ago

Parameterize was used to make sure that the template name was safe for an HTML id and for a JavaScript property.

It seems weird that using this method breaks when driving the app with selenium, what are the names of the templates that you are trying to use. Also what error do you get when running the tests?

Good point about leaving the file open though, I will put a fix in for that at least.