jumpstart 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
- data/.document +5 -0
- data/.gitignore +28 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/jumpstart +5 -0
- data/config/jumpstart_setup.yml +2 -0
- data/jumpstart.gemspec +222 -0
- data/jumpstart_templates/i0n_rails_3/.gitignore +11 -0
- data/jumpstart_templates/i0n_rails_3/_._Gemfile +5 -0
- data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +4 -0
- data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +32 -0
- data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +1 -0
- data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +1 -0
- data/jumpstart_templates/i0n_rails_3/config/deploy.rb +62 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +1 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +3 -0
- data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +14 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +40 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +11 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +37 -0
- data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +18 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +2 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +80 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +26 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +21 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +29 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +17 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +10 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +15 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +14 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +27 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +12 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +6 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +27 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +10 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +26 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +19 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +19 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +80 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +29 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +15 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +84 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +91 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +6 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +404 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +126 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +86 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +58 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +7 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +40 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +57 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +170 -0
- data/lib/jumpstart.rb +71 -0
- data/lib/jumpstart/base.rb +547 -0
- data/lib/jumpstart/doc/JumpStart.html +139 -0
- data/lib/jumpstart/doc/JumpStart/Base.html +1566 -0
- data/lib/jumpstart/doc/base_rb.html +52 -0
- data/lib/jumpstart/doc/created.rid +2 -0
- data/lib/jumpstart/doc/index.html +101 -0
- data/lib/jumpstart/doc/rdoc.css +706 -0
- data/lib/jumpstart/filetools.rb +270 -0
- data/source_templates/template_config.yml +77 -0
- data/test/fake_nginx_path/local_nginx_1.conf +81 -0
- data/test/fake_nginx_path/remote_nginx_1.conf +54 -0
- data/test/helper.rb +31 -0
- data/test/jumpstart/test_base.rb +422 -0
- data/test/jumpstart/test_filetools.rb +350 -0
- data/test/test_jumpstart.rb +9 -0
- data/test/test_jumpstart_templates/test_base/_._test_file.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_._test_file_.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_1._test_file1.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_1._test_file1_.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_10._test_file2.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_99999._test_file3.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_a._test_file4.txt +0 -0
- data/test/test_jumpstart_templates/test_base/test_file +0 -0
- data/test/test_jumpstart_templates/test_base/test_file5.txt +0 -0
- data/test/test_jumpstart_templates/test_base/test_file_.6txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/append_after_line_test.txt +6 -0
- data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_test.txt +5 -0
- data/test/test_jumpstart_templates/test_fileutils/check_source_type +5 -0
- data/test/test_jumpstart_templates/test_fileutils/check_source_type.txt +10 -0
- data/test/test_jumpstart_templates/test_fileutils/config_capistrano_source.rb +62 -0
- data/test/test_jumpstart_templates/test_fileutils/config_capistrano_test.rb +62 -0
- data/test/test_jumpstart_templates/test_fileutils/config_nginx_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/config_nginx_test.txt +82 -0
- data/test/test_jumpstart_templates/test_fileutils/hosts_test +11 -0
- data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_test.txt +4 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_files_test_2.txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_files_test_3.txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_lines_test.txt +10 -0
- data/test/test_jumpstart_templates/test_fileutils/replace_strings_test.rb +62 -0
- data/test/test_jumpstart_templates/test_template_1/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_L._test_append_to_end_of_file_remove_last_line_1.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_l._test_append_to_end_of_file_remove_last_line_2.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_50._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/jumpstart_config/test_template_1.yml +31 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_50._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_1.txt +10 -0
- data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_2.txt +10 -0
- data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_1.rb +62 -0
- data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_2.txt +23 -0
- data/test/test_jumpstart_templates/test_template_1/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +8 -0
- data/test/test_jumpstart_templates/test_template_3/jumpstart_config/test_template_3.yml +22 -0
- metadata +254 -0
data/test/helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'shoulda'
|
|
4
|
+
|
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
7
|
+
require 'jumpstart'
|
|
8
|
+
|
|
9
|
+
class Test::Unit::TestCase
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module JumpStart
|
|
14
|
+
class Base
|
|
15
|
+
|
|
16
|
+
def exit_with_success
|
|
17
|
+
puts "\n\n Exiting JumpStart...".purple
|
|
18
|
+
puts "\n Success! ".green + @project_name.green_bold + " has been created at: ".green + FileUtils.join_paths(@install_path, @project_name).green_bold + "\n\n".green
|
|
19
|
+
puts "******************************************************************************************************************************************\n"
|
|
20
|
+
@test_project = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def exit_normal
|
|
24
|
+
puts "\n\n Exiting JumpStart...".purple
|
|
25
|
+
puts "\n Goodbye!\n\n"
|
|
26
|
+
puts "******************************************************************************************************************************************\n"
|
|
27
|
+
@test_project = nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestJumpstartBase < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "Testing JumpStart::Base with a @default_template_name and @jumpstart_templates_path specified.\n" do
|
|
6
|
+
|
|
7
|
+
setup do
|
|
8
|
+
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
|
9
|
+
@test_project = JumpStart::Base.new(["test_jumpstart_project"])
|
|
10
|
+
@test_project.instance_eval do
|
|
11
|
+
@jumpstart_templates_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates"
|
|
12
|
+
@default_template_name = "test_template_1"
|
|
13
|
+
@template_name = "test_template_1"
|
|
14
|
+
@template_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_template_1"
|
|
15
|
+
set_config_file_options
|
|
16
|
+
@install_path = "#{JumpStart::ROOT_PATH}/test/destination_dir"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
teardown do
|
|
21
|
+
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "Tests for the JumpStart::Base#intialize instance method. \n" do
|
|
25
|
+
|
|
26
|
+
should "run intialize method and set instance variables" do
|
|
27
|
+
assert_equal "test_jumpstart_project", @test_project.instance_eval {@project_name}
|
|
28
|
+
assert_equal "test_template_1", @test_project.instance_eval {@template_name}
|
|
29
|
+
assert_equal YAML.load_file("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/#{@test_project.instance_eval {@template_name}}/jumpstart_config/#{@test_project.instance_eval {@template_name}}.yml"), @test_project.instance_eval {@config_file}
|
|
30
|
+
assert_equal "#{JumpStart::ROOT_PATH}/test/destination_dir", @test_project.instance_eval {@install_path}
|
|
31
|
+
assert_equal "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_template_1", @test_project.instance_eval {@template_path}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "Tests for the JumpStart::Base#lookup_existing_projects instance method. \n" do
|
|
37
|
+
|
|
38
|
+
should "run lookup_existing_projects method and return an array of existing templates" do
|
|
39
|
+
@test_project.lookup_existing_templates
|
|
40
|
+
assert_equal %w[test_template_1 test_template_2 test_template_3], @test_project.instance_eval {@existing_templates}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "Tests for the JumpStart::Base#check_project_name instance method. \n" do
|
|
46
|
+
|
|
47
|
+
context "when the project name is over three characters" do
|
|
48
|
+
|
|
49
|
+
should "return the project name unchanged and without errors" do
|
|
50
|
+
assert_equal @test_project.instance_eval {@project_name}, @test_project.instance_eval {check_project_name}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "when the project name is not empty but is not more than 3 characters" do
|
|
56
|
+
|
|
57
|
+
setup do
|
|
58
|
+
input = StringIO.new("testo\n")
|
|
59
|
+
output = StringIO.new
|
|
60
|
+
@test_project = JumpStart::Base.new(["tr"])
|
|
61
|
+
@test_project.instance_eval do
|
|
62
|
+
@input = input
|
|
63
|
+
@output = output
|
|
64
|
+
@jumpstart_templates_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates"
|
|
65
|
+
@default_template_name = "test_template_1"
|
|
66
|
+
@template_name = "test_template_1"
|
|
67
|
+
set_config_file_options
|
|
68
|
+
@install_path = "#{JumpStart::ROOT_PATH}/test/destination_dir"
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
should "read input from STDIN" do
|
|
73
|
+
assert_equal "testo\n", @test_project.input.string
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
should "ask the user to provide a longer project name" do
|
|
77
|
+
@test_project.instance_eval {check_project_name}
|
|
78
|
+
assert_equal "\e[31m\n The name tr is too short. Please enter a name at least 3 characters long.\e[0m\n" , @test_project.output.string
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
should "ask the user to provide a longer project name and then return the name of the project when a name longer than three characters is provided" do
|
|
82
|
+
@test_project.instance_eval {check_project_name}
|
|
83
|
+
assert_equal "\e[31m\n The name tr is too short. Please enter a name at least 3 characters long.\e[0m\n" , @test_project.output.string
|
|
84
|
+
assert_equal "testo", @test_project.instance_eval {check_project_name}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context "when the project name is empty or nil" do
|
|
90
|
+
|
|
91
|
+
setup do
|
|
92
|
+
input = StringIO.new("testorama\n")
|
|
93
|
+
output = StringIO.new
|
|
94
|
+
@test_project = JumpStart::Base.new([nil])
|
|
95
|
+
@test_project.instance_eval do
|
|
96
|
+
@input = input
|
|
97
|
+
@output = output
|
|
98
|
+
@jumpstart_templates_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates"
|
|
99
|
+
@default_template_name = "test_template_1"
|
|
100
|
+
@template_name = "test_template_1"
|
|
101
|
+
set_config_file_options
|
|
102
|
+
@install_path = "#{JumpStart::ROOT_PATH}/test/destination_dir"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
should "ask the user to specify a name for the project if @project_name is empty or nil" do
|
|
107
|
+
@test_project.instance_eval {check_project_name}
|
|
108
|
+
assert_equal "\e[1m\e[33m\n Enter a name for your project.\e[0m\n", @test_project.output.string
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
should "ask the user to specify a name for the project if @project_name is empty or nil and then set it when a name of at least 3 characters is provided" do
|
|
112
|
+
@test_project.instance_eval {check_project_name}
|
|
113
|
+
assert_equal "\e[1m\e[33m\n Enter a name for your project.\e[0m\n", @test_project.output.string
|
|
114
|
+
assert_equal "testorama", @test_project.instance_eval {check_project_name}
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context "Tests for the JumpStart::Base#check_template_name instance method. \n" do
|
|
122
|
+
|
|
123
|
+
should "run check_template_name method" do
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context "Tests for the JumpStart::Base#create_template instance method. \n" do
|
|
130
|
+
|
|
131
|
+
should "run create_template method" do
|
|
132
|
+
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context "Tests for the JumpStart::Base#jumpstart_options instance method. \n" do
|
|
138
|
+
|
|
139
|
+
should "run jumpstart_options method" do
|
|
140
|
+
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
context "Tests for the JumpStart::Base#configure_jumpstart instance method. \n" do
|
|
146
|
+
|
|
147
|
+
should "run configure_jumpstart method" do
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
context "Tests for the JumpStart::Base#check_install_paths instance method. \n" do
|
|
154
|
+
|
|
155
|
+
should "run check_install_paths method" do
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
context "Tests for the JumpStart::Base#create_project method instance method. \n" do
|
|
162
|
+
|
|
163
|
+
should "run create_project method" do
|
|
164
|
+
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
context "Tests for the JumpStart::Base#parse_template_dir instance method. \n" do
|
|
170
|
+
|
|
171
|
+
should "run parse_template_dir method" do
|
|
172
|
+
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
context "Tests for the JumpStart::Base#populate_files_from_append_templates instance method. \n" do
|
|
178
|
+
|
|
179
|
+
should "run populate_files_from_append_templates method" do
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
context "Tests for the JumpStart::Base#populate_files_from_line_templates instance method. \n" do
|
|
187
|
+
|
|
188
|
+
should "run populate_files_from_line_templates method" do
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
context "Tests for the JumpStart::Base#check_local_nginx_configuration instance method. \n" do
|
|
195
|
+
|
|
196
|
+
should "run check_local_nginx_configuration method" do
|
|
197
|
+
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
context "Tests for the JumpStart::Base#remove_unwanted_files instance method. \n" do
|
|
203
|
+
|
|
204
|
+
setup do
|
|
205
|
+
@test_project.instance_eval {@project_name = "test_remove"}
|
|
206
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/test_remove")
|
|
207
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/test_remove/test_remove_files")
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
should "run remove_unwanted_files method, remove files and return true." do
|
|
211
|
+
|
|
212
|
+
["/file_with_extension.txt", "/file_without_extension"].each do |x|
|
|
213
|
+
FileUtils.touch("#{JumpStart::ROOT_PATH}/test/destination_dir/test_remove/test_remove_files#{x}")
|
|
214
|
+
end
|
|
215
|
+
assert @test_project.instance_eval {remove_unwanted_files}
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context "Tests for the JumpStart::Base#run_scripts_from_yaml instance method.\n" do
|
|
221
|
+
|
|
222
|
+
should "run run_scripts_from_yaml method with the contents of :run_after_install_command symbol from ROOT_PATH/test/test_template_1/jumpstart_config/test_template_1.yml Should be nil because the install directory does not exist." do
|
|
223
|
+
assert_nil @test_project.instance_eval {run_scripts_from_yaml(:run_after_install_command)}
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
should "run the :run_after_install_command symbols scripts from ROOT_PATH/test/test_template_1/jumpstart_config/test_template_1.yml. Should work this time as I will create the directory for the script beforehand." do
|
|
227
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project")
|
|
228
|
+
assert_equal ["echo \"run after install command\""], @test_project.instance_eval {run_scripts_from_yaml(:run_after_install_command)}
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
should "run run_scripts_from_yaml method with the contents of :run_after_jumpstart symbol from ROOT_PATH/test/test_template_1/jumpstart_config/test_template_1.yml Should be nil because the install directory does not exist." do
|
|
232
|
+
assert_nil @test_project.instance_eval {run_scripts_from_yaml(:run_after_jumpstart)}
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
should "run the :run_after_jumpstart symbols scripts from ROOT_PATH/test/test_template_1/jumpstart_config/test_template_1.yml. Should work this time as I will create the directory for the script beforehand." do
|
|
236
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project")
|
|
237
|
+
assert_equal ["echo \"run after jumpstart 1st command!\"","echo \"run after jumpstart 2nd command!\""], @test_project.instance_eval {run_scripts_from_yaml(:run_after_jumpstart)}
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
should "return nil if a symbol that is not specified in YAML is passed as an argument and the install directory does not exist" do
|
|
241
|
+
assert_nil @test_project.instance_eval {run_scripts_from_yaml(:this_section_does_not_exist)}
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
should "return nil if a symbol that is not specified in the YAML is passed as an argument and the install directory has been created" do
|
|
245
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project")
|
|
246
|
+
assert_nil @test_project.instance_eval {run_scripts_from_yaml(:this_section_does_not_exist)}
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
context "Tests for the JumpStart::#check_for_strings_to_replace instance method.\n" do
|
|
252
|
+
|
|
253
|
+
setup do
|
|
254
|
+
output = StringIO.new
|
|
255
|
+
@test_project.instance_eval {@output = output}
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
should "return true if @replace_strings array contains hash data that is formatted correctly" do
|
|
259
|
+
FileUtils.mkdir_p(FileUtils.join_paths(JumpStart::ROOT_PATH, "test/destination_dir/test_jumpstart_project/test"))
|
|
260
|
+
FileUtils.touch(FileUtils.join_paths(JumpStart::ROOT_PATH, "test/destination_dir/test_jumpstart_project/test/replace_strings.txt"))
|
|
261
|
+
@test_project.instance_eval {@replace_strings = [{:target_path => "/test/replace_strings.txt", :symbols => {:jam => "strawberry", :city => "london"}}]}
|
|
262
|
+
assert(@test_project.instance_eval {check_for_strings_to_replace})
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
should "output message if data formatted correctly" do
|
|
266
|
+
FileUtils.mkdir_p(FileUtils.join_paths(JumpStart::ROOT_PATH, "test/destination_dir/test_jumpstart_project/test"))
|
|
267
|
+
FileUtils.touch(FileUtils.join_paths(JumpStart::ROOT_PATH, "test/destination_dir/test_jumpstart_project/test/replace_strings.txt"))
|
|
268
|
+
@test_project.instance_eval {@replace_strings = [{:target_path => "/test/replace_strings.txt", :symbols => {:jam => "strawberry", :city => "london"}}]}
|
|
269
|
+
@test_project.instance_eval {check_for_strings_to_replace}
|
|
270
|
+
assert_equal("\nChecking for strings to replace inside files...\n\nTarget file: \e[32m/test/replace_strings.txt\e[0m\nStrings to replace:\n\nKey: \e[32mjam\e[0m\nValue: \e[32mstrawberry\e[0m\n\nKey: \e[32mcity\e[0m\nValue: \e[32mlondon\e[0m\n\n\n", @test_project.output.string)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
should "return false if @replace_strings is empty." do
|
|
274
|
+
@test_project.instance_eval {@replace_strings = []}
|
|
275
|
+
refute(@test_project.instance_eval {check_for_strings_to_replace})
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
context "Tests for the JumpStart::#check_replace_string_pairs_for_project_name_sub instance method.\n" do
|
|
281
|
+
|
|
282
|
+
should "find :project_name symbol and return @project_name" do
|
|
283
|
+
@values = {:project_name => "some_random_name"}
|
|
284
|
+
@test_project.check_replace_string_pairs_for_project_name_sub(@values)
|
|
285
|
+
assert_equal "test_jumpstart_project", @values[:project_name]
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
should "change values hash as it contains :project_name symbol" do
|
|
289
|
+
@values = {:project_name => "some_random_name"}
|
|
290
|
+
assert_equal({:project_name => "test_jumpstart_project"}, @test_project.check_replace_string_pairs_for_project_name_sub(@values))
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
should "treat all other symbols normally and not replace anything" do
|
|
294
|
+
@values = {:womble => "uncle_bulgaria", :jam => "strawberry", :city => "london"}
|
|
295
|
+
@test_project.check_replace_string_pairs_for_project_name_sub(@values)
|
|
296
|
+
assert_equal "uncle_bulgaria", @values[:womble]
|
|
297
|
+
assert_equal "strawberry", @values[:jam]
|
|
298
|
+
assert_equal "london", @values[:city]
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
should "find :project_name symbol even if it is mixed with other symbols which should return unchanged" do
|
|
302
|
+
@values = {:womble => "uncle_bulgaria", :jam => "strawberry", :project_name => "some_random_name", :city => "london"}
|
|
303
|
+
@test_project.check_replace_string_pairs_for_project_name_sub(@values)
|
|
304
|
+
assert_equal "uncle_bulgaria", @values[:womble]
|
|
305
|
+
assert_equal "strawberry", @values[:jam]
|
|
306
|
+
assert_equal "london", @values[:city]
|
|
307
|
+
assert_equal "test_jumpstart_project", @values[:project_name]
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
should "return hash even if it is empty" do
|
|
311
|
+
@values = {}
|
|
312
|
+
assert_equal @values, @test_project.check_replace_string_pairs_for_project_name_sub(@values)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
context "Tests for the JumpStart::Base.get_line_number class method.\n" do
|
|
318
|
+
|
|
319
|
+
should "return line number as 1" do
|
|
320
|
+
assert_equal 1, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/_1._test_file1.txt")
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
should "return line number as 10" do
|
|
324
|
+
assert_equal 10, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/_10._test_file2.txt")
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
should "return line number as 99999" do
|
|
328
|
+
assert_equal 99999, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/_99999._test_file3.txt")
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
should "return line number as false" do
|
|
332
|
+
assert_equal false, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/test_file")
|
|
333
|
+
assert_equal false, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/_._test_file.txt")
|
|
334
|
+
assert_equal false, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/test_file5.txt")
|
|
335
|
+
assert_equal false, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/test_file_.6txt")
|
|
336
|
+
assert_equal false, JumpStart::Base.get_line_number("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_base/_a._test_file4.txt")
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
context "Tests for the JumpStart::Base.remove_last_line? class method.\n" do
|
|
342
|
+
|
|
343
|
+
should "return false" do
|
|
344
|
+
refute JumpStart::Base.remove_last_line?("/path/to/file.txt")
|
|
345
|
+
refute JumpStart::Base.remove_last_line?("/path/to/_._file.txt")
|
|
346
|
+
refute JumpStart::Base.remove_last_line?("_.__file.txt")
|
|
347
|
+
refute JumpStart::Base.remove_last_line?("/path/to/_R._file.txt")
|
|
348
|
+
refute JumpStart::Base.remove_last_line?("/path/to/_.1_file.txt")
|
|
349
|
+
refute JumpStart::Base.remove_last_line?("/path/to/_1._file.txt")
|
|
350
|
+
refute JumpStart::Base.remove_last_line?("/path/to/_111._file.txt")
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
should "return true" do
|
|
354
|
+
assert JumpStart::Base.remove_last_line?("/path/to/_L._file.txt")
|
|
355
|
+
assert JumpStart::Base.remove_last_line?("_L._file.txt")
|
|
356
|
+
assert JumpStart::Base.remove_last_line?("/path/to/_l._file.txt")
|
|
357
|
+
assert JumpStart::Base.remove_last_line?("_l._file.txt")
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
context "Tests for initializing and running JumpStart instances\n" do
|
|
363
|
+
|
|
364
|
+
context "Create jumpstart with the project name argument passed to it but do not start.\n" do
|
|
365
|
+
|
|
366
|
+
should "be able to create a new jumpstart with the project name as the first argument" do
|
|
367
|
+
refute_nil @test_project
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
should "have set @project_name variable to 'test_jumpstart_project'" do
|
|
371
|
+
assert_equal "test_jumpstart_project", @test_project.instance_eval {@project_name}
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
should "have set @template_name variable to 'test_template_1'" do
|
|
375
|
+
assert_equal "test_template_1", @test_project.instance_eval {@template_name}
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
should "have set @install_path to 'ROOT_PATH/test/destination_dir'" do
|
|
379
|
+
assert_equal "#{JumpStart::ROOT_PATH}/test/destination_dir", @test_project.instance_eval {@install_path}
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
should "generate a test project in ROOT_PATH/test/destination_dir/test_jumpstart_project with the test_template_1 template" do
|
|
383
|
+
@test_project.start
|
|
384
|
+
assert Dir.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project")
|
|
385
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_file_with_extension.txt")
|
|
386
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_file_without_extension")
|
|
387
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_line_file_with_extension.txt")
|
|
388
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_line_file_without_extension")
|
|
389
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_whole_file_with_extension.txt")
|
|
390
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_whole_file_without_extension")
|
|
391
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_append_file_with_extension.txt")
|
|
392
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_append_file_without_extension")
|
|
393
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_line_file_with_extension.txt")
|
|
394
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_line_file_without_extension")
|
|
395
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_whole_file_with_extension.txt")
|
|
396
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/normal_folder_name/test_whole_file_without_extension")
|
|
397
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_replace_strings/replace_strings_1.rb")
|
|
398
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_replace_strings/replace_strings_2.txt")
|
|
399
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_to_end_of_file_remove_last_line_1.txt")
|
|
400
|
+
refute File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/_L._test_append_to_end_of_file_remove_last_line_1.txt")
|
|
401
|
+
assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_to_end_of_file_remove_last_line_2.txt")
|
|
402
|
+
refute File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/_l._test_append_to_end_of_file_remove_last_line_2.txt")
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
should "remove last lines from files and append template info" do
|
|
406
|
+
@test_project.start
|
|
407
|
+
file_1 = IO.readlines("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_to_end_of_file_remove_last_line_1.txt")
|
|
408
|
+
file_2 = IO.readlines("#{JumpStart::ROOT_PATH}/test/destination_dir/test_jumpstart_project/test_append_to_end_of_file_remove_last_line_2.txt")
|
|
409
|
+
assert_equal "THIS IS THE LAST LINE\n", file_1[9]
|
|
410
|
+
assert_equal "THIS IS THE LAST LINE\n", file_2[9]
|
|
411
|
+
assert_equal "9\n", file_1[8]
|
|
412
|
+
assert_equal "9\n", file_2[8]
|
|
413
|
+
refute file_1[10]
|
|
414
|
+
refute file_2[10]
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
end
|
|
422
|
+
end
|