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
|
@ -1,7 +1,7 @@
|
||||||
module Draper
|
module Draper
|
||||||
module Generators
|
module Generators
|
||||||
class InstallGenerator < Rails::Generators::Base
|
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.'
|
desc 'Creates an ApplicationDecorator, if none exists.'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ module MiniTest
|
||||||
module Generators
|
module Generators
|
||||||
class DecoratorGenerator < Base
|
class DecoratorGenerator < Base
|
||||||
def self.source_root
|
def self.source_root
|
||||||
File.expand_path('../templates', __FILE__)
|
File.expand_path("templates", __dir__)
|
||||||
end
|
end
|
||||||
|
|
||||||
class_option :spec, type: :boolean, default: false, desc: "Use MiniTest::Spec DSL"
|
class_option :spec, type: :boolean, default: false, desc: "Use MiniTest::Spec DSL"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Rails
|
module Rails
|
||||||
module Generators
|
module Generators
|
||||||
class DecoratorGenerator < NamedBase
|
class DecoratorGenerator < NamedBase
|
||||||
source_root File.expand_path("../templates", __FILE__)
|
source_root File.expand_path("templates", __dir__)
|
||||||
check_class_collision suffix: "Decorator"
|
check_class_collision suffix: "Decorator"
|
||||||
|
|
||||||
class_option :parent, type: :string, desc: "The parent class for the generated decorator"
|
class_option :parent, type: :string, desc: "The parent class for the generated decorator"
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
module Rspec
|
module Rspec
|
||||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
module Generators
|
||||||
source_root File.expand_path('../templates', __FILE__)
|
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||||
|
source_root File.expand_path("templates", __dir__)
|
||||||
|
|
||||||
def create_spec_file
|
def create_spec_file
|
||||||
template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
|
template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
module TestUnit
|
module TestUnit
|
||||||
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
module Generators
|
||||||
source_root File.expand_path('../templates', __FILE__)
|
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
||||||
|
source_root File.expand_path("templates", __dir__)
|
||||||
|
check_class_collision suffix: "DecoratorTest"
|
||||||
|
|
||||||
def create_test_file
|
def create_test_file
|
||||||
template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
|
template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue