gigantron 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -0
- data/License.txt +20 -0
- data/Manifest.txt +65 -0
- data/PostInstall.txt +4 -0
- data/README.txt +77 -0
- data/Rakefile +4 -0
- data/app_generators/gigantron/USAGE +7 -0
- data/app_generators/gigantron/gigantron_generator.rb +87 -0
- data/app_generators/gigantron/templates/Rakefile +12 -0
- data/app_generators/gigantron/templates/database.yml.example +9 -0
- data/app_generators/gigantron/templates/initialize.rb +34 -0
- data/app_generators/gigantron/templates/lib/shoulda/active_record_helpers.rb +604 -0
- data/app_generators/gigantron/templates/lib/shoulda/general.rb +118 -0
- data/app_generators/gigantron/templates/lib/shoulda/private_helpers.rb +22 -0
- data/app_generators/gigantron/templates/tasks/import.rake +10 -0
- data/app_generators/gigantron/templates/test/tasks/test_import.rb +23 -0
- data/app_generators/gigantron/templates/test/test_helper.rb +22 -0
- data/bin/gigantron +15 -0
- data/config/hoe.rb +82 -0
- data/config/requirements.rb +15 -0
- data/gigantron_generators/mapreduce_task/USAGE +5 -0
- data/gigantron_generators/mapreduce_task/mapreduce_task_generator.rb +54 -0
- data/gigantron_generators/mapreduce_task/templates/mapreduce/mr_task.rb +22 -0
- data/gigantron_generators/mapreduce_task/templates/tasks/task.rake +5 -0
- data/gigantron_generators/mapreduce_task/templates/test/tasks/test_task.rb +22 -0
- data/gigantron_generators/migration/USAGE +5 -0
- data/gigantron_generators/migration/migration_generator.rb +61 -0
- data/gigantron_generators/migration/templates/db/migrate/migration.rb +7 -0
- data/gigantron_generators/model/USAGE +11 -0
- data/gigantron_generators/model/model_generator.rb +54 -0
- data/gigantron_generators/model/templates/models/model.rb +3 -0
- data/gigantron_generators/model/templates/test/models/test_model.rb +13 -0
- data/gigantron_generators/task/USAGE +10 -0
- data/gigantron_generators/task/task_generator.rb +51 -0
- data/gigantron_generators/task/templates/tasks/task.rake +4 -0
- data/gigantron_generators/task/templates/test/tasks/test_task.rb +22 -0
- data/lib/gigantron.rb +0 -0
- data/lib/gigantron/migrator.rb +10 -0
- data/lib/gigantron/tasks/db.rb +11 -0
- data/lib/gigantron/tasks/test.rb +30 -0
- data/lib/gigantron/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/template_database.yml +3 -0
- data/test/template_database.yml.example +9 -0
- data/test/template_migration.rb +16 -0
- data/test/test_generator_helper.rb +29 -29
- data/test/test_gigantron.rb +11 -11
- data/test/test_gigantron_generator.rb +118 -118
- 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
- data/website/index.html +224 -0
- data/website/index.txt +154 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +152 -46
@@ -0,0 +1,34 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -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'
|
data/test/test_gigantron.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestGigantron < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_truth
|
9
|
-
assert true
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestGigantron < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_truth
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
end
|
@@ -1,118 +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 "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
|
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
|