Sha256: 83b2532fc1c3a9fcde023e89baa93df62942f98feb3888990caa6a2c4443227a
Contents?: true
Size: 1014 Bytes
Versions: 2
Compression:
Stored size: 1014 Bytes
Contents
module RSpec module Rails module Controller include RSpec::Rails::App def create_controller name, content=nil file = controller_file_name(name) unless File.exist?(file) FileUtils.mkdir_p File.dirname(file) content ||= yield if block_given? File.open(file, 'w') do |f| f.puts controller_content(name, content) end end end def controller_content name, content=nil %Q{class #{name.to_s.camelize}Controller < ActionController::Base #{content} 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(controller_dir, "#{name}_controller.rb") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
generator-spec-0.4.5 | lib/generator_spec/rails_helpers/rails_controller.rb |
generator-spec-0.4.4 | lib/generator_spec/rails_helpers/rails_controller.rb |