Sha256: 34771b156f34fb7021e5f104d4be5c7ad60feb239ae816301fb90ee331c7844d
Contents?: true
Size: 1.25 KB
Versions: 7
Compression:
Stored size: 1.25 KB
Contents
module GeneratorSpecHelpers TEMPLATE_PATH = File.expand_path("../../app_templates", __FILE__) def provide_existing_routes_file copy_to_generator_root("config", "routes.rb") end def provide_existing_application_controller copy_to_generator_root("app/controllers", "application_controller.rb") end def provide_existing_user_class copy_to_generator_root("app/models", "user.rb") allow(File).to receive(:exist?).and_call_original allow(File).to receive(:exist?).with("app/models/user.rb").and_return(true) end def provide_existing_class(class_name) copy_to_generator_root("app/models", "#{class_name}.rb") allow(File).to receive(:exist?).and_call_original allow(File).to receive(:exist?).with("app/models/#{class_name}.rb").and_return(true) end private def copy_to_generator_root(destination, template) template_file = File.join(TEMPLATE_PATH, destination, template) destination = File.join(destination_root, destination) FileUtils.mkdir_p(destination) FileUtils.cp(template_file, destination) end end RSpec.configure do |config| config.include GeneratorSpecHelpers config.before(:example, :generator) do destination File.expand_path("../../tmp", __FILE__) prepare_destination end end
Version data entries
7 entries across 7 versions & 1 rubygems