Add MiniTest generators
This commit is contained in:
parent
1d7619f48f
commit
1fac02b65b
|
@ -0,0 +1,20 @@
|
||||||
|
require 'generators/mini_test'
|
||||||
|
|
||||||
|
module MiniTest
|
||||||
|
module Generators
|
||||||
|
class DecoratorGenerator < Base
|
||||||
|
def self.source_root
|
||||||
|
File.expand_path('../templates', __FILE__)
|
||||||
|
end
|
||||||
|
|
||||||
|
class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
|
||||||
|
|
||||||
|
check_class_collision suffix: "DecoratorTest"
|
||||||
|
|
||||||
|
def create_test_file
|
||||||
|
template_type = options[:spec] ? "spec" : "test"
|
||||||
|
template "decorator_#{template_type}.rb", File.join("test/decorators", class_path, "#{singular_name}_decorator_test.rb")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
require 'minitest_helper'
|
||||||
|
|
||||||
|
describe <%= class_name %>Decorator do
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
require 'minitest_helper'
|
||||||
|
|
||||||
|
class <%= class_name %>DecoratorTest < Draper::TestCase
|
||||||
|
end
|
|
@ -93,4 +93,45 @@ describe Rails::Generators::DecoratorGenerator do
|
||||||
it { should contain "class Namespace::YourModelDecoratorTest < Draper::TestCase" }
|
it { should contain "class Namespace::YourModelDecoratorTest < Draper::TestCase" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'using minitest-rails' do
|
||||||
|
before { run_generator ["YourModel", "-t=mini_test"] }
|
||||||
|
|
||||||
|
describe 'test/decorators/your_model_decorator_test.rb' do
|
||||||
|
subject { file('test/decorators/your_model_decorator_test.rb') }
|
||||||
|
it { should exist }
|
||||||
|
it { should contain "class YourModelDecoratorTest < Draper::TestCase" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'using minitest-rails with namespaced model' do
|
||||||
|
before { run_generator ["Namespace::YourModel", "-t=mini_test"] }
|
||||||
|
|
||||||
|
describe 'test/decorators/your_model_decorator_test.rb' do
|
||||||
|
subject { file('test/decorators/namespace/your_model_decorator_test.rb') }
|
||||||
|
it { should exist }
|
||||||
|
it { should contain "class Namespace::YourModelDecoratorTest < Draper::TestCase" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'using minitest-rails with spec syntax' do
|
||||||
|
before { run_generator ["YourModel", "-t=mini_test", "--spec"] }
|
||||||
|
|
||||||
|
describe 'test/decorators/your_model_decorator_test.rb' do
|
||||||
|
subject { file('test/decorators/your_model_decorator_test.rb') }
|
||||||
|
it { should exist }
|
||||||
|
it { should contain "describe YourModelDecorator" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'using minitest-rails with spec syntax with namespaced model' do
|
||||||
|
before { run_generator ["Namespace::YourModel", "-t=mini_test", "--spec"] }
|
||||||
|
|
||||||
|
describe 'test/decorators/your_model_decorator_test.rb' do
|
||||||
|
subject { file('test/decorators/namespace/your_model_decorator_test.rb') }
|
||||||
|
it { should exist }
|
||||||
|
it { should contain "describe Namespace::YourModelDecorator" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue