mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Refactor generator for TestUnit, RSpec (#816)
* Refactor generator for TestUnit * Refactor generators for RSpec * Refactor source_root for cosme
This commit is contained in:
parent
607f03e908
commit
cfe4d33733
5 changed files with 16 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
module Draper
|
||||
module Generators
|
||||
class InstallGenerator < Rails::Generators::Base
|
||||
source_root File.expand_path('../templates', __FILE__)
|
||||
source_root File.expand_path("templates", __dir__)
|
||||
|
||||
desc 'Creates an ApplicationDecorator, if none exists.'
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module MiniTest
|
|||
module Generators
|
||||
class DecoratorGenerator < Base
|
||||
def self.source_root
|
||||
File.expand_path('../templates', __FILE__)
|
||||
File.expand_path("templates", __dir__)
|
||||
end
|
||||
|
||||
class_option :spec, type: :boolean, default: false, desc: "Use MiniTest::Spec DSL"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class DecoratorGenerator < NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
source_root File.expand_path("templates", __dir__)
|
||||
check_class_collision suffix: "Decorator"
|
||||
|
||||
class_option :parent, type: :string, desc: "The parent class for the generated decorator"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
module Rspec
|
||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||
source_root File.expand_path('../templates', __FILE__)
|
||||
module Generators
|
||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||
source_root File.expand_path("templates", __dir__)
|
||||
|
||||
def create_spec_file
|
||||
template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
|
||||
def create_spec_file
|
||||
template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
module TestUnit
|
||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||
source_root File.expand_path('../templates', __FILE__)
|
||||
module Generators
|
||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||
source_root File.expand_path("templates", __dir__)
|
||||
check_class_collision suffix: "DecoratorTest"
|
||||
|
||||
def create_test_file
|
||||
template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
|
||||
def create_test_file
|
||||
template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue