templater 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/templater/actions/file.rb +1 -1
- data/lib/templater/actions/template.rb +1 -1
- data/lib/templater/cli/generator.rb +1 -2
- data/lib/templater/generator.rb +42 -32
- data/lib/templater/proxy.rb +5 -3
- data/lib/templater/spec/helpers.rb +67 -0
- data/lib/templater.rb +1 -1
- data/spec/file_spec.rb +6 -0
- data/spec/generator/{argument_spec.rb → arguments_spec.rb} +81 -0
- data/spec/generator/empty_directories_spec.rb +140 -0
- data/spec/generator/files_spec.rb +161 -0
- data/spec/generator/invocations_spec.rb +110 -1
- data/spec/generator/invoke_spec.rb +0 -88
- data/spec/generator/{option_spec.rb → options_spec.rb} +0 -0
- data/spec/generator/source_root_spec.rb +10 -0
- data/spec/generator/templates_spec.rb +173 -0
- data/spec/spec_helpers_spec.rb +85 -0
- data/spec/template_spec.rb +6 -0
- metadata +8 -14
- data/spec/generator/argument_as_array_spec.rb +0 -40
- data/spec/generator/argument_as_hash_spec.rb +0 -43
- data/spec/generator/empty_directory_spec.rb +0 -20
- data/spec/generator/file_getter_spec.rb +0 -48
- data/spec/generator/file_list_spec.rb +0 -32
- data/spec/generator/file_spec.rb +0 -53
- data/spec/generator/source_root_getter_spec.rb +0 -11
- data/spec/generator/template_getter_spec.rb +0 -48
- data/spec/generator/template_list_spec.rb +0 -32
- data/spec/generator/template_spec.rb +0 -79
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: templater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,7 +9,7 @@ autorequire: templater
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-18 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- lib/templater/generator.rb
|
65
65
|
- lib/templater/manifold.rb
|
66
66
|
- lib/templater/proxy.rb
|
67
|
+
- lib/templater/spec
|
68
|
+
- lib/templater/spec/helpers.rb
|
67
69
|
- lib/templater.rb
|
68
70
|
- spec/core_ext
|
69
71
|
- spec/core_ext/string_spec.rb
|
@@ -71,27 +73,18 @@ files:
|
|
71
73
|
- spec/file_spec.rb
|
72
74
|
- spec/generator
|
73
75
|
- spec/generator/actions_spec.rb
|
74
|
-
- spec/generator/
|
75
|
-
- spec/generator/argument_as_hash_spec.rb
|
76
|
-
- spec/generator/argument_spec.rb
|
76
|
+
- spec/generator/arguments_spec.rb
|
77
77
|
- spec/generator/desc_spec.rb
|
78
78
|
- spec/generator/destination_root_spec.rb
|
79
|
-
- spec/generator/
|
80
|
-
- spec/generator/file_getter_spec.rb
|
81
|
-
- spec/generator/file_list_spec.rb
|
82
|
-
- spec/generator/file_spec.rb
|
79
|
+
- spec/generator/empty_directories_spec.rb
|
83
80
|
- spec/generator/files_spec.rb
|
84
81
|
- spec/generator/generators_spec.rb
|
85
82
|
- spec/generator/glob_spec.rb
|
86
83
|
- spec/generator/invocations_spec.rb
|
87
84
|
- spec/generator/invoke_spec.rb
|
88
|
-
- spec/generator/
|
85
|
+
- spec/generator/options_spec.rb
|
89
86
|
- spec/generator/render_spec.rb
|
90
|
-
- spec/generator/source_root_getter_spec.rb
|
91
87
|
- spec/generator/source_root_spec.rb
|
92
|
-
- spec/generator/template_getter_spec.rb
|
93
|
-
- spec/generator/template_list_spec.rb
|
94
|
-
- spec/generator/template_spec.rb
|
95
88
|
- spec/generator/templates_spec.rb
|
96
89
|
- spec/manifold_spec.rb
|
97
90
|
- spec/results
|
@@ -103,6 +96,7 @@ files:
|
|
103
96
|
- spec/results/random.rbs
|
104
97
|
- spec/results/simple_erb.rbs
|
105
98
|
- spec/spec_helper.rb
|
99
|
+
- spec/spec_helpers_spec.rb
|
106
100
|
- spec/template_spec.rb
|
107
101
|
- spec/templater_spec.rb
|
108
102
|
- spec/templates
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.argument as array' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
@generator_class.argument(0, :monkey)
|
8
|
-
@generator_class.argument(1, :llama, :as => :array)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should allow assignment of arrays" do
|
12
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', %w(an array))
|
13
|
-
|
14
|
-
instance.monkey.should == 'a monkey'
|
15
|
-
instance.llama[0].should == 'an'
|
16
|
-
instance.llama[1].should == 'array'
|
17
|
-
|
18
|
-
instance.llama = %w(another donkey)
|
19
|
-
instance.llama[0].should == 'another'
|
20
|
-
instance.llama[1].should == 'donkey'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should convert a single argument to an array" do
|
24
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', 'test')
|
25
|
-
instance.llama[0].should == 'test'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should consume the remaining arguments and convert them to an array" do
|
29
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', 'test', 'silver', 'river')
|
30
|
-
instance.llama[0].should == 'test'
|
31
|
-
instance.llama[1].should == 'silver'
|
32
|
-
instance.llama[2].should == 'river'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should raise error if the argument is not an array" do
|
36
|
-
instance = @generator_class.new('/tmp')
|
37
|
-
lambda { instance.llama = :not_an_array }.should raise_error(Templater::MalformattedArgumentError)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.argument as hash' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
@generator_class.argument(0, :monkey)
|
8
|
-
@generator_class.argument(1, :llama, :as => :hash)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should allow assignment of hashes" do
|
12
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', { :hash => 'blah' })
|
13
|
-
|
14
|
-
instance.monkey.should == 'a monkey'
|
15
|
-
instance.llama[:hash].should == 'blah'
|
16
|
-
|
17
|
-
instance.llama = { :me_s_a => :hash }
|
18
|
-
instance.llama[:me_s_a].should == :hash
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should convert a key/value pair to a hash" do
|
22
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', 'test:unit')
|
23
|
-
instance.llama['test'].should == 'unit'
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should consume the remaining arguments and convert them to a hash if they are key/value pairs" do
|
27
|
-
instance = @generator_class.new('/tmp', {}, 'a monkey', 'test:unit', 'john:silver', 'river:road')
|
28
|
-
instance.llama['test'].should == 'unit'
|
29
|
-
instance.llama['john'].should == 'silver'
|
30
|
-
instance.llama['river'].should == 'road'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should raise an error if one of the remaining arguments is not a key/value pair" do
|
34
|
-
lambda { @generator_class.new('/tmp', {}, 'a monkey', 'a:llama', 'duck:llama', 'not_a_pair', 'pair:blah') }.should raise_error(Templater::MalformattedArgumentError)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should raise error if the argument is neither a hash nor a key/value pair" do
|
38
|
-
lambda { @generator_class.new('/tmp', {}, 'a monkey', 23) }.should raise_error(Templater::MalformattedArgumentError)
|
39
|
-
instance = @generator_class.new('/tmp')
|
40
|
-
lambda { instance.llama = :not_a_hash }.should raise_error(Templater::MalformattedArgumentError)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, ".empty_directory" do
|
4
|
-
before do
|
5
|
-
@generator_class = Class.new(Templater::Generator)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "adds directory path to list of directories that should be created" do
|
9
|
-
lambda do
|
10
|
-
@generator_class.empty_directory :bin, "bin"
|
11
|
-
end.should change(@generator_class.empty_directories, :size)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "calculates directory path relatively to destination root" do
|
15
|
-
@generator_class.empty_directory :bin, "bin/swf"
|
16
|
-
|
17
|
-
@instance = @generator_class.new("/tmp/destination")
|
18
|
-
@instance.empty_directory(:bin).destination.should == "/tmp/destination/bin/swf"
|
19
|
-
end
|
20
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '#file' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
@generator_class.class_eval do
|
8
|
-
def source_root
|
9
|
-
'/tmp/source'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find a file by name" do
|
15
|
-
@generator_class.file(:blah1, 'blah.rb')
|
16
|
-
@generator_class.file(:blah2, 'blah2.rb')
|
17
|
-
|
18
|
-
instance = @generator_class.new('/tmp')
|
19
|
-
|
20
|
-
instance.file(:blah1).name.should == :blah1
|
21
|
-
instance.file(:blah1).source.should == '/tmp/source/blah.rb'
|
22
|
-
instance.file(:blah1).destination.should == '/tmp/blah.rb'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should not return a file with an option that does not match." do
|
26
|
-
@generator_class.option :framework, :default => :rails
|
27
|
-
|
28
|
-
@generator_class.file(:merb, 'blah.rb', :framework => :merb)
|
29
|
-
@generator_class.file(:rails, 'blah2.rb', :framework => :rails)
|
30
|
-
@generator_class.file(:none, 'blah2.rb')
|
31
|
-
|
32
|
-
instance = @generator_class.new('/tmp')
|
33
|
-
|
34
|
-
instance.file(:rails).name.should == :rails
|
35
|
-
instance.file(:merb).should be_nil
|
36
|
-
instance.file(:none).name.should == :none
|
37
|
-
|
38
|
-
instance.framework = :merb
|
39
|
-
instance.file(:rails).should be_nil
|
40
|
-
instance.file(:merb).name.should == :merb
|
41
|
-
instance.file(:none).name.should == :none
|
42
|
-
|
43
|
-
instance.framework = nil
|
44
|
-
instance.file(:rails).should be_nil
|
45
|
-
instance.file(:merb).should be_nil
|
46
|
-
instance.file(:none).name.should == :none
|
47
|
-
end
|
48
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.file_list' do
|
4
|
-
|
5
|
-
it "should add a series of files given a list as heredoc" do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
|
8
|
-
@generator_class.should_receive(:file).with(:app_model_rb, 'app/model.rb')
|
9
|
-
@generator_class.should_receive(:file).with(:spec_model_rb, 'spec/model.rb')
|
10
|
-
@generator_class.should_receive(:file).with(:donkey_poo_css, 'donkey/poo.css')
|
11
|
-
@generator_class.should_receive(:file).with(:john_smith_file_rb, 'john/smith/file.rb')
|
12
|
-
|
13
|
-
@generator_class.file_list <<-LIST
|
14
|
-
app/model.rb
|
15
|
-
spec/model.rb
|
16
|
-
donkey/poo.css
|
17
|
-
john/smith/file.rb
|
18
|
-
LIST
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should add a series of files given a list as array" do
|
22
|
-
@generator_class = Class.new(Templater::Generator)
|
23
|
-
|
24
|
-
@generator_class.should_receive(:file).with(:app_model_rb, 'app/model.rb')
|
25
|
-
@generator_class.should_receive(:file).with(:spec_model_rb, 'spec/model.rb')
|
26
|
-
@generator_class.should_receive(:file).with(:donkey_poo_css, 'donkey/poo.css')
|
27
|
-
@generator_class.should_receive(:file).with(:john_smith_file_rb, 'john/smith/file.rb')
|
28
|
-
|
29
|
-
@generator_class.file_list(%w(app/model.rb spec/model.rb donkey/poo.css john/smith/file.rb))
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/spec/generator/file_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.file' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should add a file with source and destination" do
|
10
|
-
@generator_class.file(:my_template, 'path/to/source.rbt', 'path/to/destination.rb')
|
11
|
-
@instance = @generator_class.new('/tmp/destination')
|
12
|
-
|
13
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
14
|
-
|
15
|
-
@instance.file(:my_template).source.should == '/tmp/source/path/to/source.rbt'
|
16
|
-
@instance.file(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
17
|
-
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should add a file with source and infer destination " do
|
21
|
-
@generator_class.file(:my_template, 'path/to/file.rb')
|
22
|
-
@instance = @generator_class.new('/tmp/destination')
|
23
|
-
|
24
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
25
|
-
|
26
|
-
@instance.file(:my_template).source.should == '/tmp/source/path/to/file.rb'
|
27
|
-
@instance.file(:my_template).destination.should == '/tmp/destination/path/to/file.rb'
|
28
|
-
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should add a file and convert an instruction encoded in the destination, but not one encoded in the source" do
|
32
|
-
@generator_class.file(:my_template, 'template/%some_method%.rbt', 'template/%another_method%.rb')
|
33
|
-
@instance = @generator_class.new('/tmp/destination')
|
34
|
-
|
35
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
36
|
-
@instance.should_not_receive(:some_method)
|
37
|
-
@instance.should_receive(:another_method).at_least(:once).and_return('beast')
|
38
|
-
|
39
|
-
@instance.file(:my_template).source.should == '/tmp/source/template/%some_method%.rbt'
|
40
|
-
@instance.file(:my_template).destination.should == "/tmp/destination/template/beast.rb"
|
41
|
-
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should add a file and leave an encoded instruction be if it doesn't exist as a method" do
|
45
|
-
@generator_class.file(:my_template, 'template/blah.rbt', 'template/%some_method%.rb')
|
46
|
-
@instance = @generator_class.new('/tmp/destination')
|
47
|
-
|
48
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
49
|
-
|
50
|
-
@instance.file(:my_template).destination.should == "/tmp/destination/template/%some_method%.rb"
|
51
|
-
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
52
|
-
end
|
53
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '#source_root' do
|
4
|
-
it "try to retrieve the source root from the class" do
|
5
|
-
@generator_class = Class.new(Templater::Generator)
|
6
|
-
@generator_class.should_receive(:source_root).and_return('/tmp/source')
|
7
|
-
|
8
|
-
instance = @generator_class.new('/tmp')
|
9
|
-
instance.source_root.should == '/tmp/source'
|
10
|
-
end
|
11
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '#template' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
@generator_class.class_eval do
|
8
|
-
def source_root
|
9
|
-
'/tmp/source'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find a template by name" do
|
15
|
-
@generator_class.template(:blah1, 'blah.rb')
|
16
|
-
@generator_class.template(:blah2, 'blah2.rb')
|
17
|
-
|
18
|
-
instance = @generator_class.new('/tmp')
|
19
|
-
|
20
|
-
instance.template(:blah1).name.should == :blah1
|
21
|
-
instance.template(:blah1).source.should == '/tmp/source/blah.rbt'
|
22
|
-
instance.template(:blah1).destination.should == '/tmp/blah.rb'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should not return a template with an option that does not match." do
|
26
|
-
@generator_class.option :framework, :default => :rails
|
27
|
-
|
28
|
-
@generator_class.template(:merb, 'blah.rb', :framework => :merb)
|
29
|
-
@generator_class.template(:rails, 'blah2.rb', :framework => :rails)
|
30
|
-
@generator_class.template(:none, 'blah2.rb')
|
31
|
-
|
32
|
-
instance = @generator_class.new('/tmp')
|
33
|
-
|
34
|
-
instance.template(:rails).name.should == :rails
|
35
|
-
instance.template(:merb).should be_nil
|
36
|
-
instance.template(:none).name.should == :none
|
37
|
-
|
38
|
-
instance.framework = :merb
|
39
|
-
instance.template(:rails).should be_nil
|
40
|
-
instance.template(:merb).name.should == :merb
|
41
|
-
instance.template(:none).name.should == :none
|
42
|
-
|
43
|
-
instance.framework = nil
|
44
|
-
instance.template(:rails).should be_nil
|
45
|
-
instance.template(:merb).should be_nil
|
46
|
-
instance.template(:none).name.should == :none
|
47
|
-
end
|
48
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.template_list' do
|
4
|
-
|
5
|
-
it "should add a series of templates given a list as heredoc" do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
|
8
|
-
@generator_class.should_receive(:template).with(:app_model_rb, 'app/model.rb')
|
9
|
-
@generator_class.should_receive(:template).with(:spec_model_rb, 'spec/model.rb')
|
10
|
-
@generator_class.should_receive(:template).with(:donkey_poo_css, 'donkey/poo.css')
|
11
|
-
@generator_class.should_receive(:template).with(:john_smith_file_rb, 'john/smith/file.rb')
|
12
|
-
|
13
|
-
@generator_class.template_list <<-LIST
|
14
|
-
app/model.rb
|
15
|
-
spec/model.rb
|
16
|
-
donkey/poo.css
|
17
|
-
john/smith/file.rb
|
18
|
-
LIST
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should add a series of templates given a list as array" do
|
22
|
-
@generator_class = Class.new(Templater::Generator)
|
23
|
-
|
24
|
-
@generator_class.should_receive(:template).with(:app_model_rb, 'app/model.rb')
|
25
|
-
@generator_class.should_receive(:template).with(:spec_model_rb, 'spec/model.rb')
|
26
|
-
@generator_class.should_receive(:template).with(:donkey_poo_css, 'donkey/poo.css')
|
27
|
-
@generator_class.should_receive(:template).with(:john_smith_file_rb, 'john/smith/file.rb')
|
28
|
-
|
29
|
-
@generator_class.template_list(%w(app/model.rb spec/model.rb donkey/poo.css john/smith/file.rb))
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Templater::Generator, '.template' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@generator_class = Class.new(Templater::Generator)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should add a template with source and destination" do
|
10
|
-
@generator_class.template(:my_template, 'path/to/source.rbt', 'path/to/destination.rb')
|
11
|
-
@instance = @generator_class.new('/tmp/destination')
|
12
|
-
|
13
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
14
|
-
|
15
|
-
@instance.template(:my_template).source.should == '/tmp/source/path/to/source.rbt'
|
16
|
-
@instance.template(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
17
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should add a template with absolute source and destination" do
|
21
|
-
@generator_class.template(:my_template, '/path/to/source.rbt', '/path/to/destination.rb')
|
22
|
-
@instance = @generator_class.new('/tmp/destination')
|
23
|
-
|
24
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
25
|
-
|
26
|
-
@instance.template(:my_template).source.should == '/path/to/source.rbt'
|
27
|
-
@instance.template(:my_template).destination.should == '/path/to/destination.rb'
|
28
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should add a template with destination and infer the source" do
|
32
|
-
@generator_class.template(:my_template, 'path/to/destination.rb')
|
33
|
-
@instance = @generator_class.new('/tmp/destination')
|
34
|
-
|
35
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
36
|
-
|
37
|
-
@instance.template(:my_template).source.should == '/tmp/source/path/to/destination.rbt'
|
38
|
-
@instance.template(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
39
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should add a template with a block" do
|
43
|
-
@generator_class.template(:my_template) do
|
44
|
-
source 'blah.rbt'
|
45
|
-
destination "gurr#{Process.pid.to_s}.rb"
|
46
|
-
end
|
47
|
-
@instance = @generator_class.new('/tmp/destination')
|
48
|
-
|
49
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
50
|
-
|
51
|
-
@instance.template(:my_template).source.should == '/tmp/source/blah.rbt'
|
52
|
-
@instance.template(:my_template).destination.should == "/tmp/destination/gurr#{Process.pid.to_s}.rb"
|
53
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should add a template and convert an with an instruction encoded in the destination, but not one encoded in the source" do
|
57
|
-
@generator_class.template(:my_template, 'template/%some_method%.rbt', 'template/%another_method%.rb')
|
58
|
-
@instance = @generator_class.new('/tmp/destination')
|
59
|
-
|
60
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
61
|
-
@instance.should_not_receive(:some_method)
|
62
|
-
@instance.should_receive(:another_method).at_least(:once).and_return('beast')
|
63
|
-
|
64
|
-
@instance.template(:my_template).source.should == '/tmp/source/template/%some_method%.rbt'
|
65
|
-
@instance.template(:my_template).destination.should == "/tmp/destination/template/beast.rb"
|
66
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should add a template and leave an encoded instruction be if it doesn't exist as a method" do
|
70
|
-
@generator_class.template(:my_template, 'template/blah.rbt', 'template/%some_method%.rb')
|
71
|
-
@instance = @generator_class.new('/tmp/destination')
|
72
|
-
|
73
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
74
|
-
|
75
|
-
@instance.template(:my_template).destination.should == "/tmp/destination/template/%some_method%.rb"
|
76
|
-
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|