Module: Teabag::SpecHelper

Defined in:
app/helpers/teabag/spec_helper.rb

Instance Method Summary collapse

Instance Method Details

#asset_src(dep, instrument = false) ⇒ Object



30
31
32
33
34
# File 'app/helpers/teabag/spec_helper.rb', line 30

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

#javascript_include_tag_for_teabag(*sources) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/teabag/spec_helper.rb', line 16

def javascript_include_tag_for_teabag(*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


3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/teabag/spec_helper.rb', line 3

def stylesheet_link_tag_for_teabag(*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