Sha256: 7503de6d60e8099c82de285dc5b8ab40e93f3e41ca8fec22e7be07276e4f96eb

Contents?: true

Size: 966 Bytes

Versions: 12

Compression:

Stored size: 966 Bytes

Contents

require 'coffee-script'

class Netzke::TestingController < ActionController::Base
  before_filter :set_locale

  def components
    component_name = params[:class].gsub("::", "_").underscore
    render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:class]}', :height => #{params[:height] || 400} %>",
           :layout => true
  end

  def specs
    coffee = spec_file(params[:name])
    render text: CoffeeScript.compile(coffee)
  end

  private

  def set_locale
    # if params[:locale] is nil then I18n.default_locale will be used
    I18n.locale = params[:locale]
  end

  def spec_file(name)
    spec_root = Pathname.new(Netzke::Testing.spec_root || Rails.root)

    path = spec_root.join "spec/features/javascripts/#{name}_spec.js.coffee"

    if !File.exists?(File.expand_path(path, __FILE__))
      path = spec_root.join "spec/features/javascripts/#{name}.js.coffee"
    end

    File.read(File.expand_path(path, __FILE__))
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
netzke-testing-1.0.1.0 app/controllers/netzke/testing_controller.rb
netzke-testing-1.0.0.0 app/controllers/netzke/testing_controller.rb
netzke-testing-1.0.0.0.pre app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.3 app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.2 app/controllers/netzke/testing_controller.rb
netzke-testing-0.11.2 app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.1 app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.0 app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.0.beta2 app/controllers/netzke/testing_controller.rb
netzke-testing-0.12.0.beta app/controllers/netzke/testing_controller.rb
netzke-testing-0.11.1 app/controllers/netzke/testing_controller.rb
netzke-testing-0.11.0 app/controllers/netzke/testing_controller.rb