-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed hobo_model_controller generator - added missing view.html.erb t…
…emplate
- Loading branch information
Showing
9 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
hobo/rails_generators/hobo_model_controller/templates/view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1><%= class_name %>#<%= action %></h1> | ||
<p>Find me in <%= path %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
begin | ||
require File.dirname(__FILE__) + '/test_helper' | ||
rescue LoadError | ||
require 'test/unit' | ||
end | ||
require 'fileutils' | ||
|
||
# Must set before requiring generator libs. | ||
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT) | ||
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME) | ||
app_root = File.join(TMP_ROOT, PROJECT_NAME) | ||
if defined?(APP_ROOT) | ||
APP_ROOT.replace(app_root) | ||
else | ||
APP_ROOT = app_root | ||
end | ||
if defined?(RAILS_ROOT) | ||
RAILS_ROOT.replace(app_root) | ||
else | ||
RAILS_ROOT = app_root | ||
end | ||
|
||
begin | ||
require 'rubigen' | ||
rescue LoadError | ||
require 'rubygems' | ||
require 'rubigen' | ||
end | ||
require 'rubigen/helpers/generator_test_helper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'test/unit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require File.join(File.dirname(__FILE__), "test_generator_helper.rb") | ||
|
||
require 'rails_generator' | ||
|
||
class TestHoboModelControllerGenerator < Test::Unit::TestCase | ||
include RubiGen::GeneratorTestHelper | ||
|
||
def setup | ||
bare_setup | ||
end | ||
|
||
def teardown | ||
bare_teardown | ||
end | ||
|
||
# Some generator-related assertions: | ||
# assert_generated_file(name, &block) # block passed the file contents | ||
# assert_directory_exists(name) | ||
# assert_generated_class(name, &block) | ||
# assert_generated_module(name, &block) | ||
# assert_generated_test_for(name, &block) | ||
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file | ||
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet) | ||
# | ||
# Other helper methods are: | ||
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files) | ||
# bare_setup - place this in setup method to create the APP_ROOT folder for each test | ||
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test | ||
|
||
def test_generator_without_options | ||
name = "MyModel" | ||
run_generator('hobo_model_controller', [name], sources) | ||
assert_directory_exists 'app/controllers' | ||
assert_directory_exists 'app/helpers' | ||
assert_directory_exists 'app/views' | ||
assert_directory_exists 'test/functional' | ||
|
||
assert_generated_file 'app/controllers/my_models_controller.rb' | ||
assert_generated_class 'app/controllers/my_models_controller' | ||
assert_generated_file 'app/helpers/my_models_helper.rb' | ||
assert_generated_file 'test/functional/my_models_controller_test.rb' | ||
end | ||
|
||
def test_generator_with_views | ||
name = "MyModel" | ||
run_generator('hobo_model_controller', [name, 'index', 'show'], sources) | ||
assert_directory_exists 'app/controllers' | ||
assert_directory_exists 'app/helpers' | ||
assert_directory_exists 'app/views' | ||
assert_directory_exists 'test/functional' | ||
|
||
assert_generated_file 'app/controllers/my_models_controller.rb' | ||
assert_generated_class 'app/controllers/my_models_controller' | ||
assert_generated_file 'app/helpers/my_models_helper.rb' | ||
assert_generated_file 'test/functional/my_models_controller_test.rb' | ||
|
||
assert_generated_file 'app/views/my_models/index.html.erb' | ||
assert_generated_file 'app/views/my_models/show.html.erb' | ||
end | ||
|
||
private | ||
def sources | ||
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path)) | ||
] | ||
end | ||
|
||
def generator_path | ||
"rails_generators" | ||
end | ||
end |