spec/support/generator_spec_helpers.rb in clearance-1.14.0 vs spec/support/generator_spec_helpers.rb in clearance-1.14.1
- old
+ new
@@ -16,11 +16,11 @@
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")
+ copy_to_generator_root("app/models", versionize_template("user.rb"))
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with("app/models/user.rb").and_return(true)
end
private
@@ -29,9 +29,17 @@
template_file = File.join(TEMPLATE_PATH, destination, template)
destination = File.join(destination_root, destination)
FileUtils.mkdir_p(destination)
FileUtils.cp(template_file, destination)
+ end
+
+ def versionize_template(template_file)
+ if Rails.version >= "5.0.0"
+ template_file = ["rails5", template_file].join("/")
+ end
+
+ template_file
end
end
RSpec.configure do |config|
config.include GeneratorSpecHelpers