gigantron 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/test/test_generator_helper.rb +29 -29
- data/test/test_gigantron_generator.rb +118 -114
- data/test/test_helper.rb +4 -4
- data/test/test_mapreduce_task_generator.rb +50 -50
- data/test/test_migration_generator.rb +49 -49
- data/test/test_model_generator.rb +53 -53
- data/test/test_task_generator.rb +48 -48
- metadata +48 -109
- data/History.txt +0 -15
- data/License.txt +0 -20
- data/Manifest.txt +0 -62
- data/PostInstall.txt +0 -4
- data/README.txt +0 -77
- data/Rakefile +0 -4
- data/app_generators/gigantron/USAGE +0 -7
- data/app_generators/gigantron/gigantron_generator.rb +0 -81
- data/app_generators/gigantron/templates/Rakefile +0 -12
- data/app_generators/gigantron/templates/database.yml +0 -8
- data/app_generators/gigantron/templates/initialize.rb +0 -34
- data/app_generators/gigantron/templates/tasks/import.rake +0 -10
- data/app_generators/gigantron/templates/test/tasks/test_import.rb +0 -23
- data/app_generators/gigantron/templates/test/test_helper.rb +0 -7
- data/bin/gigantron +0 -15
- data/config/hoe.rb +0 -82
- data/config/requirements.rb +0 -15
- data/gigantron_generators/mapreduce_task/USAGE +0 -5
- data/gigantron_generators/mapreduce_task/mapreduce_task_generator.rb +0 -54
- data/gigantron_generators/mapreduce_task/templates/mapreduce/mr_task.rb +0 -22
- data/gigantron_generators/mapreduce_task/templates/tasks/task.rake +0 -5
- data/gigantron_generators/mapreduce_task/templates/test/tasks/test_task.rb +0 -22
- data/gigantron_generators/migration/USAGE +0 -5
- data/gigantron_generators/migration/migration_generator.rb +0 -61
- data/gigantron_generators/migration/templates/db/migrate/migration.rb +0 -7
- data/gigantron_generators/model/USAGE +0 -11
- data/gigantron_generators/model/model_generator.rb +0 -54
- data/gigantron_generators/model/templates/models/model.rb +0 -3
- data/gigantron_generators/model/templates/test/models/test_model.rb +0 -13
- data/gigantron_generators/task/USAGE +0 -10
- data/gigantron_generators/task/task_generator.rb +0 -51
- data/gigantron_generators/task/templates/tasks/task.rake +0 -4
- data/gigantron_generators/task/templates/test/tasks/test_task.rb +0 -22
- data/lib/gigantron/migrator.rb +0 -10
- data/lib/gigantron/tasks/db.rb +0 -11
- data/lib/gigantron/tasks/test.rb +0 -30
- data/lib/gigantron/version.rb +0 -9
- data/lib/gigantron.rb +0 -0
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/template_database.yml +0 -9
- data/test/template_database.yml.example +0 -9
- data/test/template_migration.rb +0 -16
- data/website/index.html +0 -213
- data/website/index.txt +0 -145
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
@@ -1,29 +1,29 @@
|
|
1
|
-
begin
|
2
|
-
require File.dirname(__FILE__) + '/test_helper'
|
3
|
-
rescue LoadError
|
4
|
-
require 'test/unit'
|
5
|
-
end
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
# Must set before requiring generator libs.
|
9
|
-
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
10
|
-
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
11
|
-
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
12
|
-
if defined?(APP_ROOT)
|
13
|
-
APP_ROOT.replace(app_root)
|
14
|
-
else
|
15
|
-
APP_ROOT = app_root
|
16
|
-
end
|
17
|
-
if defined?(RAILS_ROOT)
|
18
|
-
RAILS_ROOT.replace(app_root)
|
19
|
-
else
|
20
|
-
RAILS_ROOT = app_root
|
21
|
-
end
|
22
|
-
|
23
|
-
begin
|
24
|
-
require 'rubigen'
|
25
|
-
rescue LoadError
|
26
|
-
require 'rubygems'
|
27
|
-
require 'rubigen'
|
28
|
-
end
|
29
|
-
require 'rubigen/helpers/generator_test_helper'
|
1
|
+
begin
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
|
+
rescue LoadError
|
4
|
+
require 'test/unit'
|
5
|
+
end
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
# Must set before requiring generator libs.
|
9
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
10
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
11
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
12
|
+
if defined?(APP_ROOT)
|
13
|
+
APP_ROOT.replace(app_root)
|
14
|
+
else
|
15
|
+
APP_ROOT = app_root
|
16
|
+
end
|
17
|
+
if defined?(RAILS_ROOT)
|
18
|
+
RAILS_ROOT.replace(app_root)
|
19
|
+
else
|
20
|
+
RAILS_ROOT = app_root
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'rubigen'
|
25
|
+
rescue LoadError
|
26
|
+
require 'rubygems'
|
27
|
+
require 'rubigen'
|
28
|
+
end
|
29
|
+
require 'rubigen/helpers/generator_test_helper'
|
@@ -1,114 +1,118 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
class TestGigantronGenerator < Test::Unit::TestCase
|
4
|
-
include RubiGen::GeneratorTestHelper
|
5
|
-
|
6
|
-
def setup
|
7
|
-
bare_setup
|
8
|
-
end
|
9
|
-
|
10
|
-
def teardown
|
11
|
-
bare_teardown
|
12
|
-
end
|
13
|
-
|
14
|
-
should "generate correct directory and file structure" do
|
15
|
-
run_generator('gigantron', [APP_ROOT], sources)
|
16
|
-
assert_directory_exists "tasks/"
|
17
|
-
assert_generated_file "tasks/import.rake"
|
18
|
-
assert_directory_exists "test/"
|
19
|
-
assert_generated_file "test/test_helper.rb"
|
20
|
-
assert_directory_exists "test/tasks/"
|
21
|
-
assert_generated_file "test/tasks/test_import.rb"
|
22
|
-
assert_directory_exists "test/models/"
|
23
|
-
assert_directory_exists "lib/"
|
24
|
-
assert_directory_exists "
|
25
|
-
|
26
|
-
|
27
|
-
assert_generated_file "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
should "create
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
"
|
88
|
-
end
|
89
|
-
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestGigantronGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
bare_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
bare_teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
should "generate correct directory and file structure" do
|
15
|
+
run_generator('gigantron', [APP_ROOT], sources)
|
16
|
+
assert_directory_exists "tasks/"
|
17
|
+
assert_generated_file "tasks/import.rake"
|
18
|
+
assert_directory_exists "test/"
|
19
|
+
assert_generated_file "test/test_helper.rb"
|
20
|
+
assert_directory_exists "test/tasks/"
|
21
|
+
assert_generated_file "test/tasks/test_import.rb"
|
22
|
+
assert_directory_exists "test/models/"
|
23
|
+
assert_directory_exists "lib/"
|
24
|
+
assert_directory_exists "lib/shoulda/"
|
25
|
+
assert_generated_file "lib/shoulda/general.rb"
|
26
|
+
assert_generated_file "lib/shoulda/private_helpers.rb"
|
27
|
+
assert_generated_file "lib/shoulda/active_record_helpers.rb"
|
28
|
+
assert_directory_exists "models/"
|
29
|
+
assert_directory_exists "db/"
|
30
|
+
assert_directory_exists "script/"
|
31
|
+
assert_generated_file "script/generate"
|
32
|
+
assert_generated_file "database.yml.example"
|
33
|
+
assert_generated_file "Rakefile"
|
34
|
+
assert_generated_file "initialize.rb"
|
35
|
+
end
|
36
|
+
|
37
|
+
context "Generated project" do
|
38
|
+
setup do
|
39
|
+
run_generator('gigantron', [APP_ROOT], sources)
|
40
|
+
|
41
|
+
silence_warnings { GTRON_ENV = :test }
|
42
|
+
ENV["GTRON_ENV"] = "test"
|
43
|
+
|
44
|
+
initialize_gigantron
|
45
|
+
configure_gigantron_db
|
46
|
+
get_db_conn(GTRON_ENV)
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with migration and model" do
|
50
|
+
setup do
|
51
|
+
run_generator('model', ['Foo'], sources)
|
52
|
+
|
53
|
+
create_test_migration
|
54
|
+
get_db_conn(GTRON_ENV)
|
55
|
+
|
56
|
+
ENV["VERBOSE"] = "false"
|
57
|
+
Gigantron.migrate_dbs
|
58
|
+
end
|
59
|
+
|
60
|
+
should "create test db" do
|
61
|
+
assert File.exists?("#{APP_ROOT}/db/test.sqlite3")
|
62
|
+
end
|
63
|
+
|
64
|
+
should "create table foos and populate" do
|
65
|
+
assert_equal Foo.find(:all).size, 2
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with Rake tasks" do
|
70
|
+
setup do
|
71
|
+
@rake = Rake::Application.new
|
72
|
+
Rake.application = @rake
|
73
|
+
load "#{APP_ROOT}/tasks/import.rake"
|
74
|
+
end
|
75
|
+
|
76
|
+
teardown { Rake.application = nil }
|
77
|
+
|
78
|
+
should "run empty import task" do
|
79
|
+
assert @rake['import'].invoke
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def sources
|
86
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path)),
|
87
|
+
RubiGen::PathSource.new(:test_components, File.join(File.dirname(__FILE__),"..", "gigantron_generators"))]
|
88
|
+
end
|
89
|
+
|
90
|
+
def generator_path
|
91
|
+
"app_generators"
|
92
|
+
end
|
93
|
+
|
94
|
+
def initialize_gigantron
|
95
|
+
require File.join(APP_ROOT, "initialize.rb")
|
96
|
+
require 'gigantron/migrator'
|
97
|
+
end
|
98
|
+
|
99
|
+
def configure_gigantron_db
|
100
|
+
if !File.exists? "test/template_database.yml"
|
101
|
+
flunk "No Database Configuration. Configure test DB in 'test/template_database.yml'!"
|
102
|
+
end
|
103
|
+
File.open("#{APP_ROOT}/database.yml", "w") do |f|
|
104
|
+
f.write ERB.new(
|
105
|
+
File.read("test/template_database.yml")).result(binding)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def create_test_migration
|
110
|
+
if !File.exists? "#{APP_ROOT}/db/migrate/001_create_foos.rb"
|
111
|
+
run_generator('migration', ['CreateFoos'], sources)
|
112
|
+
end
|
113
|
+
|
114
|
+
assert File.exists?("#{APP_ROOT}/db/migrate/001_create_foos.rb")
|
115
|
+
FileUtils.cp("test/template_migration.rb",
|
116
|
+
"#{APP_ROOT}/db/migrate/001_create_foos.rb")
|
117
|
+
end
|
118
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'shoulda'
|
4
|
-
require File.dirname(__FILE__) + '/../lib/gigantron'
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'shoulda'
|
4
|
+
require File.dirname(__FILE__) + '/../lib/gigantron'
|
@@ -1,50 +1,50 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestMapreduceTaskGenerator < Test::Unit::TestCase
|
5
|
-
include RubiGen::GeneratorTestHelper
|
6
|
-
|
7
|
-
def setup
|
8
|
-
bare_setup
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
bare_teardown
|
13
|
-
end
|
14
|
-
|
15
|
-
# Some generator-related assertions:
|
16
|
-
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
-
# assert_directory_exists(name)
|
18
|
-
# assert_generated_class(name, &block)
|
19
|
-
# assert_generated_module(name, &block)
|
20
|
-
# assert_generated_test_for(name, &block)
|
21
|
-
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
-
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
-
#
|
24
|
-
# Other helper methods are:
|
25
|
-
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
-
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
-
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
-
|
29
|
-
def test_generator_without_options
|
30
|
-
name = "myapp"
|
31
|
-
run_generator('mapreduce_task', [name], sources)
|
32
|
-
assert_directory_exists "mapreduce/"
|
33
|
-
assert_generated_file "mapreduce/mr_#{name}.rb"
|
34
|
-
assert_directory_exists "tasks/"
|
35
|
-
assert_generated_file "tasks/#{name}.rake"
|
36
|
-
assert_directory_exists "test/"
|
37
|
-
assert_directory_exists "test/tasks/"
|
38
|
-
assert_generated_file "test/tasks/test_#{name}.rb"
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def sources
|
43
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
44
|
-
]
|
45
|
-
end
|
46
|
-
|
47
|
-
def generator_path
|
48
|
-
"gigantron_generators"
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestMapreduceTaskGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
name = "myapp"
|
31
|
+
run_generator('mapreduce_task', [name], sources)
|
32
|
+
assert_directory_exists "mapreduce/"
|
33
|
+
assert_generated_file "mapreduce/mr_#{name}.rb"
|
34
|
+
assert_directory_exists "tasks/"
|
35
|
+
assert_generated_file "tasks/#{name}.rake"
|
36
|
+
assert_directory_exists "test/"
|
37
|
+
assert_directory_exists "test/tasks/"
|
38
|
+
assert_generated_file "test/tasks/test_#{name}.rb"
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def sources
|
43
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def generator_path
|
48
|
+
"gigantron_generators"
|
49
|
+
end
|
50
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestMigrationGenerator < Test::Unit::TestCase
|
5
|
-
include RubiGen::GeneratorTestHelper
|
6
|
-
|
7
|
-
def setup
|
8
|
-
bare_setup
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
bare_teardown
|
13
|
-
end
|
14
|
-
|
15
|
-
# Some generator-related assertions:
|
16
|
-
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
-
# assert_directory_exists(name)
|
18
|
-
# assert_generated_class(name, &block)
|
19
|
-
# assert_generated_module(name, &block)
|
20
|
-
# assert_generated_test_for(name, &block)
|
21
|
-
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
-
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
-
#
|
24
|
-
# Other helper methods are:
|
25
|
-
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
-
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
-
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
-
|
29
|
-
def test_generator_without_options
|
30
|
-
name = "CreateFoo"
|
31
|
-
run_generator('migration', [name], sources)
|
32
|
-
assert_directory_exists "db/"
|
33
|
-
assert_directory_exists "db/migrate/"
|
34
|
-
assert_generated_file "db/migrate/001_create_foo.rb"
|
35
|
-
name2 = "AlterFoo"
|
36
|
-
run_generator('migration', [name2], sources)
|
37
|
-
assert_generated_file "db/migrate/002_alter_foo.rb"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def sources
|
42
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
43
|
-
]
|
44
|
-
end
|
45
|
-
|
46
|
-
def generator_path
|
47
|
-
"gigantron_generators"
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestMigrationGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
name = "CreateFoo"
|
31
|
+
run_generator('migration', [name], sources)
|
32
|
+
assert_directory_exists "db/"
|
33
|
+
assert_directory_exists "db/migrate/"
|
34
|
+
assert_generated_file "db/migrate/001_create_foo.rb"
|
35
|
+
name2 = "AlterFoo"
|
36
|
+
run_generator('migration', [name2], sources)
|
37
|
+
assert_generated_file "db/migrate/002_alter_foo.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def sources
|
42
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def generator_path
|
47
|
+
"gigantron_generators"
|
48
|
+
end
|
49
|
+
end
|
@@ -1,53 +1,53 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestModelGenerator < Test::Unit::TestCase
|
5
|
-
include RubiGen::GeneratorTestHelper
|
6
|
-
|
7
|
-
def setup
|
8
|
-
bare_setup
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
bare_teardown
|
13
|
-
end
|
14
|
-
|
15
|
-
# Some generator-related assertions:
|
16
|
-
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
-
# assert_directory_exists(name)
|
18
|
-
# assert_generated_class(name, &block)
|
19
|
-
# assert_generated_module(name, &block)
|
20
|
-
# assert_generated_test_for(name, &block)
|
21
|
-
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
-
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
-
#
|
24
|
-
# Other helper methods are:
|
25
|
-
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
-
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
-
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
-
|
29
|
-
def test_generator_without_options
|
30
|
-
name = "FooBaz"
|
31
|
-
run_generator('model', [name], sources)
|
32
|
-
assert_directory_exists "models/"
|
33
|
-
assert_generated_file "models/foo_baz.rb"
|
34
|
-
assert_directory_exists "test/"
|
35
|
-
assert_directory_exists "test/models/"
|
36
|
-
assert_generated_file "test/models/test_foo_baz.rb"
|
37
|
-
|
38
|
-
#check migration
|
39
|
-
assert_directory_exists "db/"
|
40
|
-
assert_directory_exists "db/migrate/"
|
41
|
-
assert_generated_file "db/migrate/001_create_foo_bazs.rb"
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def sources
|
46
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
def generator_path
|
51
|
-
"gigantron_generators"
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestModelGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
name = "FooBaz"
|
31
|
+
run_generator('model', [name], sources)
|
32
|
+
assert_directory_exists "models/"
|
33
|
+
assert_generated_file "models/foo_baz.rb"
|
34
|
+
assert_directory_exists "test/"
|
35
|
+
assert_directory_exists "test/models/"
|
36
|
+
assert_generated_file "test/models/test_foo_baz.rb"
|
37
|
+
|
38
|
+
#check migration
|
39
|
+
assert_directory_exists "db/"
|
40
|
+
assert_directory_exists "db/migrate/"
|
41
|
+
assert_generated_file "db/migrate/001_create_foo_bazs.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def sources
|
46
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def generator_path
|
51
|
+
"gigantron_generators"
|
52
|
+
end
|
53
|
+
end
|