contao 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,14 +8,22 @@ module TechnoGate
8
8
  REPO_URL = 'https://github.com/TechnoGate/contao_template.git'
9
9
 
10
10
  def generate
11
+ require_global_config
11
12
  clone_template
12
13
  rename_project
13
14
  run_bundle_install
15
+ run_rake_contao_generate_initializer
14
16
  commit_everything
15
17
  replace_origin_with_template
16
18
  end
17
19
 
18
20
  protected
21
+ def require_global_config
22
+ unless File.exists? TechnoGate::Contao::Application.global_config_path
23
+ raise 'Contao config file does not exist, please run "contao generate config" first'
24
+ end
25
+ end
26
+
19
27
  def clone_template
20
28
  git_args = "clone --recursive #{REPO_URL} #{project_path}"
21
29
  Contao::System.safe_system 'git', *git_args.split(' ')
@@ -34,6 +42,17 @@ module TechnoGate
34
42
  end
35
43
  end
36
44
 
45
+ def run_rake_contao_generate_initializer
46
+ Dir.chdir project_path do
47
+ Contao::System.safe_system(
48
+ 'bundle',
49
+ 'exec',
50
+ 'rake',
51
+ 'contao:generate_initializer'
52
+ )
53
+ end
54
+ end
55
+
37
56
  def commit_everything
38
57
  Dir.chdir project_path do
39
58
  Contao::System.safe_system('git', 'add', '-A', '.')
@@ -1,3 +1,3 @@
1
1
  module Contao
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
@@ -86,7 +86,7 @@ namespace :contao do
86
86
  end
87
87
 
88
88
  desc 'Generate an initializer'
89
- task :generate_initializer do
89
+ task :generate_initializer => :environment do
90
90
  require 'contao/generators/contao_initializer'
91
91
 
92
92
  TechnoGate::Contao::Generators::ContaoInitializer.new(path: Rails.root).generate
@@ -15,22 +15,26 @@ module TechnoGate
15
15
  @path = '/root/my_awesome_project'
16
16
  end
17
17
 
18
- it_should_behave_like "Generator"
18
+ it_should_behave_like 'Generator'
19
19
 
20
- describe "#generate" do
20
+ describe '#generate' do
21
21
  before :each do
22
+ klass.any_instance.stub :require_global_config
22
23
  klass.any_instance.stub :clone_template
23
24
  klass.any_instance.stub :rename_project
24
25
  klass.any_instance.stub :run_bundle_install
26
+ klass.any_instance.stub :run_rake_contao_generate_initializer
25
27
  klass.any_instance.stub :commit_everything
26
28
  klass.any_instance.stub :replace_origin_with_template
27
29
  System.stub(:system)
28
30
  end
29
31
 
30
- it "should have the following call stack" do
32
+ it 'should have the following call stack' do
33
+ subject.should_receive(:require_global_config).once.ordered
31
34
  subject.should_receive(:clone_template).once.ordered
32
35
  subject.should_receive(:rename_project).once.ordered
33
36
  subject.should_receive(:run_bundle_install).once.ordered
37
+ subject.should_receive(:run_rake_contao_generate_initializer).once.ordered
34
38
  subject.should_receive(:commit_everything).once.ordered
35
39
  subject.should_receive(:replace_origin_with_template).once.ordered
36
40
 
@@ -38,10 +42,28 @@ module TechnoGate
38
42
  end
39
43
  end
40
44
 
41
- describe "#clone_template" do
45
+ describe '#require_global_config', :fakefs do
46
+ it {should respond_to :require_global_config}
47
+
48
+ it 'should check if the global config exists' do
49
+ File.should_receive(:exists?).with("#{ENV['HOME']}/.contao/config.yml").once.and_return true
50
+
51
+ subject.send :require_global_config
52
+ end
53
+
54
+ it 'should raise an error if it does not exist' do
55
+ File.should_receive(:exists?).with("#{ENV['HOME']}/.contao/config.yml").once.and_return false
56
+
57
+ expect do
58
+ subject.send :require_global_config
59
+ end.to raise_error
60
+ end
61
+ end
62
+
63
+ describe '#clone_template' do
42
64
  it {should respond_to :clone_template}
43
65
 
44
- it "should clone the repository to path provided to the initializer" do
66
+ it 'should clone the repository to path provided to the initializer' do
45
67
  System.should_receive(:system).with(
46
68
  'git',
47
69
  'clone',
@@ -54,14 +76,14 @@ module TechnoGate
54
76
  end
55
77
  end
56
78
 
57
- describe "#rename_project", :fakefs do
79
+ describe '#rename_project', :fakefs do
58
80
  before :each do
59
81
  stub_filesystem!(:application_name => 'contao_template')
60
82
  end
61
83
 
62
84
  it {should respond_to :rename_project}
63
85
 
64
- it "should rename the application" do
86
+ it 'should rename the application' do
65
87
  subject.send :rename_project
66
88
 
67
89
  File.read('/root/my_awesome_project/config/application.rb').should =~
@@ -69,40 +91,65 @@ module TechnoGate
69
91
  end
70
92
  end
71
93
 
72
- describe "#run_bundle_install", :fakefs do
94
+ describe '#run_bundle_install', :fakefs do
73
95
  before :each do
74
96
  stub_filesystem!
75
97
  end
76
98
 
77
99
  it {should respond_to :run_bundle_install}
78
100
 
79
- it "should change the folder to the path" do
101
+ it 'should change the folder to the path' do
80
102
  Dir.should_receive(:chdir).once
81
103
 
82
104
  subject.send :run_bundle_install
83
105
  end
84
106
 
85
- it "should run bundle install" do
107
+ it 'should run bundle install' do
86
108
  System.should_receive(:system).with('bundle', 'install').once.and_return true
87
109
 
88
110
  subject.send :run_bundle_install
89
111
  end
90
112
  end
91
113
 
92
- describe "#commit_everything", :fakefs do
114
+ describe '#run_rake_contao_generate_initializer', :fakefs do
115
+ before :each do
116
+ stub_filesystem!
117
+ end
118
+
119
+ it {should respond_to :run_rake_contao_generate_initializer}
120
+
121
+ it 'should change the folder to the path' do
122
+ Dir.should_receive(:chdir).once
123
+
124
+ subject.send :run_rake_contao_generate_initializer
125
+ end
126
+
127
+ it 'should run bundle exec rake contao:generate_initializer' do
128
+ System.should_receive(:system).with(
129
+ 'bundle',
130
+ 'exec',
131
+ 'rake',
132
+ 'contao:generate_initializer'
133
+ ).once.and_return true
134
+
135
+ subject.send :run_rake_contao_generate_initializer
136
+ end
137
+ end
138
+
139
+ describe '#commit_everything', :fakefs do
93
140
  before :each do
94
141
  stub_filesystem!
95
142
  end
96
143
 
97
144
  it {should respond_to :commit_everything}
98
145
 
99
- it "should change the folder to the path" do
146
+ it 'should change the folder to the path' do
100
147
  Dir.should_receive(:chdir).once
101
148
 
102
149
  subject.send :commit_everything
103
150
  end
104
151
 
105
- it "should run git commit -am 'Generated project'" do
152
+ it 'should commit everything' do
106
153
  System.should_receive(:system).with('git', 'add', '-A', '.').once.ordered.and_return true
107
154
  System.should_receive(:system).with(
108
155
  'git',
@@ -122,13 +169,13 @@ module TechnoGate
122
169
 
123
170
  it {should respond_to :replace_origin_with_template}
124
171
 
125
- it "should change the folder to the path" do
172
+ it 'should change the folder to the path' do
126
173
  Dir.should_receive(:chdir).once
127
174
 
128
175
  subject.send :replace_origin_with_template
129
176
  end
130
177
 
131
- it "should replace origin with template" do
178
+ it 'should replace origin with template' do
132
179
  System.should_receive(:system).with('git', 'remote', 'rm', 'origin').once.ordered.and_return true
133
180
  System.should_receive(:system).with(
134
181
  'git',
@@ -145,4 +192,3 @@ module TechnoGate
145
192
  end
146
193
  end
147
194
  end
148
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  segments:
211
211
  - 0
212
- hash: 1216300722657407589
212
+ hash: -745897341125477947
213
213
  requirements: []
214
214
  rubyforge_project:
215
215
  rubygems_version: 1.8.23