Sha256: bdffa6d9faf7655bfc16f114a6144bba31748cc88798425e4c81da25fd05b52c

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

require 'rails_generator'
require 'shenandoah/rails/locator'

module Shenandoah
  module Generators
    class ShenSpecGenerator < ::Rails::Generator::NamedBase
      def manifest
        spec_path = Shenandoah::Rails::Locator.new.spec_path.sub %r{^#{RAILS_ROOT}/}, ''
        record do |m|
          m.directory "#{spec_path}/#{File.dirname(file_path)}"
          m.template 'javascript_spec.js.erb', "#{spec_path}/#{file_path}_spec.js"
          m.template 'fixture.html.erb', "#{spec_path}/#{file_path}.html"
        end
      end

      def file_path
        super.sub /_spec$/, ''
      end

      def javascript_class_name
        klass, *mods_rev = class_name.sub(/Spec$/, '').split('::').reverse
        mod_spec = mods_rev.reverse.collect { |m| m.downcase }.join('.')
        [mod_spec, klass].reject { |p| p == "" }.join '.'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
rsutphin-shenandoah-0.1.0 rails_generators/shen_spec/shen_spec_generator.rb
shenandoah-0.1.0 rails_generators/shen_spec/shen_spec_generator.rb