Sha256: 6955f08625026d33d15de1ccada678e8c299e23cdb57f8ed1607bb64f86f6a44

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

module RSpec  
  module Rails
    module Controller
      def create_controller name
        file =  controller_file_name(name)
        unless File.exist?(file)    
          FileUtils.mkdir_p File.dirname(file)
          File.open(file, 'w') do |f|  
            f.puts controller_content
          end
        end
      end  

      def controller_content name
        %Q{class #{name.camelize}Controller < ActionController::Base
        end}        
      end

      def remove_controller name
        file = controller_file_name(name)
        FileUtils.rm_f(file) if File.exist?(file)
      end

      def remove_controllers *names
        names.each{|name| remove_controller name }
      end     
      
      def controller_file_name name
        File.join(::Rails.root, "app/controllers/#{name}.rb")
      end        
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_for_generators-0.2.1 lib/rspec_for_generators/rails_helpers/rails_controller.rb
rspec_for_generators-0.2.0 lib/rspec_for_generators/rails_helpers/rails_controller.rb