Sha256: 338e4d73a095ce27988f919608f38eaaf1b23b72bcc2f56d9b4af3652ac42308
Contents?: true
Size: 821 Bytes
Versions: 3
Compression:
Stored size: 821 Bytes
Contents
module RSpec::Rails module Helper def create_helper name, content=nil file = helper_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 helper_content(content) end end end def helper_content name, content=nil %Q{class #{name.to_s.camelize}Helper #{content} 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
Version data entries
3 entries across 3 versions & 1 rubygems