test/unit/generator_test.rb in sprout-1.0.11.pre vs test/unit/generator_test.rb in sprout-1.0.13.pre
- old
+ new
@@ -29,10 +29,12 @@
@fixture = File.join fixtures, 'generators', 'fake'
@templates = File.join fixtures, 'generators', 'templates'
@string_io = StringIO.new
@generator = configure_generator FakeGenerator.new
+ Sprout::Generator.register OtherFakeGenerator
+
FileUtils.mkdir_p @fixture
end
teardown do
remove_file @fixture
@@ -55,10 +57,18 @@
assert_matches /public class SomeProject/, content
assert_matches /public function SomeProject/, content
end
end
+ should "call another generator" do
+ @generator.external = true
+ @generator.execute
+ assert_file File.join(@fixture, 'some_project', 'SomeOtherOtherFile') do |content|
+ assert_matches /We are agents of the free?/, content
+ end
+ end
+
should "copy templates from the first found template path" do
@generator.input = 'some_project'
@generator.band_name = 'R.E.M.'
@generator.execute
assert_file File.join(@fixture, 'some_project', 'SomeFile') do |content|
@@ -108,11 +118,11 @@
@string_io.expects(:puts).never
@generator.execute
end
should "only have one param in class definition" do
- assert_equal 2, FakeGenerator.static_parameter_collection.size
+ assert_equal 3, FakeGenerator.static_parameter_collection.size
assert_equal 2, FakeGenerator.static_default_value_collection.size
end
should "not update superclass parameter collection" do
assert_equal 6, Sprout::Generator::Base.static_parameter_collection.size
@@ -183,21 +193,23 @@
end
private
def configure_generator generator
- generator.input = 'some_project'
+ generator.input = 'some_project'
generator.logger = @string_io
generator.path = @fixture
generator.templates << @templates
generator
end
##
# This is a fake Generator that should
# exercise the inputs.
class FakeGenerator < Sprout::Generator::Base
+
+ add_param :external, Boolean
##
# Register this generator by input, type and version
#register :application, :fake, '1.0.pre'
@@ -223,12 +235,23 @@
def manifest
directory input do
template 'SomeFile'
template 'SomeOtherFile', 'OtherFileTemplate'
+ generator :other_fake if external
directory src do
template "#{class_name}.as", 'Main.as'
end
+ end
+ end
+ end
+
+ class OtherFakeGenerator < Sprout::Generator::Base
+ add_param :band_name, String, { :default => 'Barf' }
+
+ def manifest
+ directory input do
+ template 'SomeOtherOtherFile', 'OtherFileTemplate'
end
end
end
context "an unregistered generator" do