Sha256: 706aba5e0a24a245d167901451f873384b81c8e2e90e617f50a97748b547df9b

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

module RSpec  
  module Rails
    module Helper
      def create_helper name
        file =  helper_file_name(name)
        unless File.exist?(file)    
          FileUtils.mkdir_p File.dirname(file)
          File.open(file, 'w') do |f|  
            f.puts helper_content
          end
        end
      end  

      def helper_content name
        %Q{class #{name.camelize}Helper
        end}        
      end

      def remove_model name
        file = helper_file_name(name)
        FileUtils.rm_f(file) if File.exist?(file)
      end

      def remove_helpers *names
        names.each{|name| remove_helper name }
      end
      
      protected
      
      def helper_file_name name
        File.join(::Rails.root, "app/helpers/#{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_helper.rb
rspec_for_generators-0.2.0 lib/rspec_for_generators/rails_helpers/rails_helper.rb