Sha256: 0480676d5fab2045c25eb252988d98a571527f6950c18ef2706febfc7929e2ec

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

module Teaspoon::SpecHelper

  def stylesheet_link_tag_for_teaspoon(*sources)
    sources.collect do |source|
      asset = defined?(lookup_asset_for_path) ? lookup_asset_for_path(source, type: :stylesheet) : asset_paths.asset_for(source, "css")
      if asset.respond_to?(:logical_path)
        asset.to_a.map do |dep|
          stylesheet_link_tag(dep.pathname.to_s, href: asset_src(dep, source), type: "text/css").split("\n")
        end
      else
        stylesheet_link_tag(source) unless source.blank?
      end
    end.flatten.uniq.join("\n").html_safe
  end

  def javascript_include_tag_for_teaspoon(*sources)
    options = sources.extract_options!
    sources.collect do |source|
      asset = defined?(lookup_asset_for_path) ? lookup_asset_for_path(source, type: :javascript) : asset_paths.asset_for(source, "js")
      if asset.respond_to?(:logical_path)
        asset.to_a.map do |dep|
          javascript_include_tag(dep.pathname.to_s, src: asset_src(dep, options[:instrument]), type: "text/javascript").split("\n")
        end
      else
        javascript_include_tag(source) unless source.blank?
      end
    end.flatten.uniq.join("\n").html_safe
  end

  def asset_src(dep, instrument = false)
    params = "?body=1"
    params << "&instrument=1" if instrument && @suite && @suite.instrument_file?(dep.pathname.to_s)
    "#{Rails.application.config.assets.prefix}/#{dep.logical_path}#{params}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
teaspoon-0.7.8 app/helpers/teaspoon/spec_helper.rb
teaspoon-0.7.7 app/helpers/teaspoon/spec_helper.rb
teaspoon-0.7.6 app/helpers/teaspoon/spec_helper.rb
teaspoon-0.7.5 app/helpers/teaspoon/spec_helper.rb
teaspoon-0.7.4 app/helpers/teaspoon/spec_helper.rb