Module: Cactus::Rails::ViewHelper

Extended by:
ActiveSupport::Concern
Defined in:
lib/cactus/rails/helpers/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#cactusObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cactus/rails/helpers/view_helper.rb', line 10

def cactus
  return unless ::Rails.env.test? || ::Rails.env.development?

  html  = "<script src='/assets/cactus.js' type='text/javascript'></script>"

  dir   = "#{::Rails.root}/public"
  specs = Dir[File.join(dir, "/cactus_spec", "/*spec.js")]
  specs.each do |file|
    filename = file[-(file.size - dir.size)..-1]

    html += "<script src='#{filename}' type='text/javascript'></script>"
  end

  html.html_safe
end