Sha256: 51e21cca0344637aac70c56c17c01638d65519e32b701a02a1a34ad3d4835a17
Contents?: true
Size: 823 Bytes
Versions: 4
Compression:
Stored size: 823 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(name, content) end end end def helper_content name, content=nil %Q{class #{name.to_s.camelize}Helper #{content} end} end def remove_helper 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}_helper.rb") end end end
Version data entries
4 entries across 4 versions & 1 rubygems