padrino-gen 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.rdoc +10 -10
  2. data/Rakefile +4 -15
  3. data/bin/padrino-gen +3 -0
  4. data/lib/padrino-gen/generators/actions.rb +10 -4
  5. data/lib/padrino-gen/generators/app/app.rb.tt +2 -2
  6. data/lib/padrino-gen/generators/components/mocks/mocha.rb +9 -0
  7. data/lib/padrino-gen/generators/components/mocks/rr.rb +11 -0
  8. data/lib/padrino-gen/generators/components/orms/activerecord.rb +112 -0
  9. data/lib/padrino-gen/generators/components/orms/couchrest.rb +44 -0
  10. data/lib/padrino-gen/generators/components/orms/datamapper.rb +86 -0
  11. data/lib/padrino-gen/generators/components/orms/mongoid.rb +68 -0
  12. data/lib/padrino-gen/generators/components/orms/mongomapper.rb +43 -0
  13. data/lib/padrino-gen/generators/components/orms/sequel.rb +71 -0
  14. data/lib/padrino-gen/generators/components/renderers/erb.rb +3 -0
  15. data/lib/padrino-gen/generators/components/renderers/haml.rb +3 -0
  16. data/lib/padrino-gen/generators/components/scripts/extcore.rb +4 -0
  17. data/lib/padrino-gen/generators/components/scripts/jquery.rb +4 -0
  18. data/lib/padrino-gen/generators/components/scripts/mootools.rb +4 -0
  19. data/lib/padrino-gen/generators/components/scripts/prototype.rb +5 -0
  20. data/lib/padrino-gen/generators/components/scripts/rightjs.rb +4 -0
  21. data/lib/padrino-gen/generators/components/stylesheets/less.rb +33 -0
  22. data/lib/padrino-gen/generators/components/stylesheets/sass.rb +25 -0
  23. data/lib/padrino-gen/generators/components/tests/bacon.rb +64 -0
  24. data/lib/padrino-gen/generators/components/tests/cucumber.rb +63 -0
  25. data/lib/padrino-gen/generators/components/tests/riot.rb +69 -0
  26. data/lib/padrino-gen/generators/components/tests/rspec.rb +66 -0
  27. data/lib/padrino-gen/generators/components/tests/shoulda.rb +70 -0
  28. data/lib/padrino-gen/generators/components/tests/testspec.rb +63 -0
  29. data/lib/padrino-gen/generators/controller.rb +4 -4
  30. data/lib/padrino-gen/generators/project/config/apps.rb.tt +12 -4
  31. data/lib/padrino-gen/generators/project/config/boot.rb +1 -1
  32. data/lib/padrino-gen/generators/project.rb +1 -1
  33. data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
  34. data/lib/padrino-gen/generators/templates/scripts/ext-core.js +8 -0
  35. data/lib/padrino-gen/generators/templates/scripts/jquery.js +150 -15
  36. data/lib/padrino-gen/padrino-tasks/activerecord.rb +1 -1
  37. data/lib/padrino-gen/padrino-tasks/mongomapper.rb +1 -1
  38. data/lib/padrino-gen/padrino-tasks/sequel.rb +37 -0
  39. data/lib/padrino-gen.rb +9 -2
  40. data/padrino-gen.gemspec +30 -28
  41. data/test/helper.rb +5 -0
  42. data/test/test_app_generator.rb +11 -19
  43. data/test/test_cli.rb +4 -6
  44. data/test/test_controller_generator.rb +43 -33
  45. data/test/test_mailer_generator.rb +11 -17
  46. data/test/test_migration_generator.rb +42 -47
  47. data/test/test_model_generator.rb +90 -89
  48. data/test/test_project_generator.rb +43 -39
  49. metadata +30 -28
  50. data/VERSION +0 -1
  51. data/lib/padrino-gen/generators/components/mocks/mocha_gen.rb +0 -20
  52. data/lib/padrino-gen/generators/components/mocks/rr_gen.rb +0 -22
  53. data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +0 -123
  54. data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +0 -56
  55. data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +0 -97
  56. data/lib/padrino-gen/generators/components/orms/mongoid_gen.rb +0 -80
  57. data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +0 -55
  58. data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +0 -83
  59. data/lib/padrino-gen/generators/components/renderers/erb_gen.rb +0 -14
  60. data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +0 -15
  61. data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +0 -15
  62. data/lib/padrino-gen/generators/components/scripts/mootools_gen.rb +0 -15
  63. data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +0 -16
  64. data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +0 -15
  65. data/lib/padrino-gen/generators/components/stylesheets/less_gen.rb +0 -43
  66. data/lib/padrino-gen/generators/components/stylesheets/sass_gen.rb +0 -35
  67. data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +0 -75
  68. data/lib/padrino-gen/generators/components/tests/cucumber_test_gen.rb +0 -76
  69. data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +0 -80
  70. data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +0 -85
  71. data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +0 -81
  72. data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +0 -74
@@ -0,0 +1,33 @@
1
+ LESS_INIT = (<<-LESS).gsub(/^ {10}/, '') unless defined?(LESS_INIT)
2
+ # Enables support for Less template reloading for rack.
3
+ # Store Less files by default within 'app/stylesheets/'
4
+ # See http://github.com/kelredd/rack-less for more details.
5
+
6
+ module LessInitializer
7
+ def self.registered(app)
8
+ require 'rack/less'
9
+ # optional - use as necessary
10
+ Rack::Less.configure do |config|
11
+ config.compress = true
12
+ # other configs ...
13
+ end
14
+ app.use Rack::Less,
15
+ :root => app.root,
16
+ :source => 'stylesheets/',
17
+ :public => 'public/',
18
+ :hosted_at => '/stylesheets'
19
+ end
20
+ end
21
+
22
+ LESS
23
+
24
+ LESS_REGISTER = (<<-LESSR).gsub(/^ {10}/, '') unless defined?(LESS_REGISTER)
25
+ register LessInitializer\n
26
+ LESSR
27
+
28
+ def setup_stylesheet
29
+ require_dependencies 'less', 'rack-less'
30
+ create_file destination_root('/lib/less_plugin.rb'), LESS_INIT
31
+ inject_into_file destination_root('/app/app.rb'), LESS_REGISTER, :after => "configure do\n"
32
+ empty_directory destination_root('/app/stylesheets')
33
+ end
@@ -0,0 +1,25 @@
1
+ SASS_INIT = (<<-SASS).gsub(/^ {10}/, '') unless defined?(SASS_INIT)
2
+ # Enables support for SASS template reloading in rack applications.
3
+ # See http://nex-3.com/posts/88-sass-supports-rack for more details.
4
+ # Store SASS files (by default) within 'app/stylesheets'
5
+
6
+ module SassInitializer
7
+ def self.registered(app)
8
+ require 'sass/plugin/rack'
9
+ Sass::Plugin.options[:template_location] = Padrino.root("app/stylesheets")
10
+ Sass::Plugin.options[:css_location] = Padrino.root("public/stylesheets")
11
+ app.use Sass::Plugin::Rack
12
+ end
13
+ end
14
+ SASS
15
+
16
+ SASS_REGISTER = (<<-SASSR).gsub(/^ {10}/, '') unless defined?(SASS_REGISTER)
17
+ register SassInitializer\n
18
+ SASSR
19
+
20
+ def setup_stylesheet
21
+ require_dependencies 'haml'
22
+ create_file destination_root('/lib/sass_plugin.rb'), SASS_INIT
23
+ inject_into_file destination_root('/app/app.rb'), SASS_REGISTER, :after => "configure do\n"
24
+ empty_directory destination_root('/app/stylesheets')
25
+ end
@@ -0,0 +1,64 @@
1
+ BACON_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_SETUP)
2
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+
5
+ class Bacon::Context
6
+ include Rack::Test::Methods
7
+ end
8
+
9
+ def app
10
+ ##
11
+ # You can handle all padrino applications using instead:
12
+ # Padrino.application
13
+ CLASS_NAME.tap { |app| }
14
+ end
15
+ TEST
16
+
17
+ BACON_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_CONTROLLER_TEST)
18
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
19
+
20
+ describe "!NAME!Controller" do
21
+ it 'returns text at root' do
22
+ get "/"
23
+ last_response.body.should == "some text"
24
+ end
25
+ end
26
+ TEST
27
+
28
+ BACON_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_RAKE)
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.pattern = '**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ TEST
36
+
37
+ BACON_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_MODEL_TEST)
38
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
39
+
40
+ describe "!NAME! Model" do
41
+ it 'can be created' do
42
+ @!DNAME! = !NAME!.new
43
+ @!DNAME!.should.not.be.nil
44
+ end
45
+ end
46
+ TEST
47
+
48
+ # Setup the testing configuration helper and dependencies
49
+ def setup_test
50
+ require_dependencies 'bacon', :group => 'test'
51
+ insert_test_suite_setup BACON_SETUP, :path => 'test/test_config.rb'
52
+ create_file destination_root("test/test.rake"), BACON_RAKE
53
+ end
54
+
55
+ # Generates a controller test given the controllers name
56
+ def generate_controller_test(name)
57
+ bacon_contents = BACON_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
58
+ create_file destination_root("test/controllers/","#{name.to_s.underscore}_controller_test.rb"), bacon_contents, :skip => true
59
+ end
60
+
61
+ def generate_model_test(name)
62
+ bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
63
+ create_file destination_root("test/models/#{name.to_s.underscore}_test.rb"), bacon_contents, :skip => true
64
+ end
@@ -0,0 +1,63 @@
1
+ apply_component_for(:rspec, :test)
2
+
3
+ CUCUMBER_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(CUCUMBER_SETUP)
4
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
5
+ require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
6
+
7
+ require 'capybara/cucumber'
8
+ require 'spec/expectations'
9
+
10
+ ##
11
+ # You can handle all padrino applications using instead:
12
+ # Padrino.application
13
+ Capybara.app = CLASS_NAME.tap { |app| }
14
+ TEST
15
+
16
+ CUCUMBER_YML = (<<-TEST).gsub(/^ {10}/, '') unless defined?(CUCUMBER_YML)
17
+ default: --tags ~@wip --strict features
18
+ html_report: --tags ~@wip --strict --format html --out=features_report.html features
19
+ TEST
20
+
21
+ CUCUMBER_FEATURE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(CUCUMBER_FEATURE)
22
+ Feature: Addition
23
+ In order to avoid silly mistakes
24
+ As a math idiot
25
+ I want to be told the sum of two numbers
26
+
27
+ Scenario: Add two numbers
28
+ Given I visit the calculator page
29
+ And I fill in '50' for 'first'
30
+ And I fill in '70' for 'second'
31
+ When I press 'Add'
32
+ Then I should see 'Answer: 120'
33
+ TEST
34
+
35
+ CUCUMBER_STEP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(CUCUMBER_STEP)
36
+ Given /^I visit the calculator page$/ do
37
+ visit '/add'
38
+ end
39
+
40
+ Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
41
+ fill_in(field, :with => value)
42
+ end
43
+
44
+ When /^I press '(.*)'$/ do |name|
45
+ click_button(name)
46
+ end
47
+
48
+ Then /^I should see '(.*)'$/ do |text|
49
+ response_body.should contain(/#\{text}/m)
50
+ end
51
+ TEST
52
+
53
+ def setup_test
54
+ require_dependencies 'cucumber', :group => 'test'
55
+ require_dependencies 'capybara', :group => 'test'
56
+ insert_test_suite_setup CUCUMBER_SETUP, :path => "features/support/env.rb"
57
+ create_file destination_root("features/add.feature"), CUCUMBER_FEATURE
58
+ create_file destination_root("features/step_definitions/add_steps.rb"), CUCUMBER_STEP
59
+ create_file destination_root("cucumber.yml"), CUCUMBER_YML
60
+ require_dependencies 'rspec', :require => 'spec', :group => 'test'
61
+ insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
62
+ create_file destination_root("spec/spec.rake"), RSPEC_RAKE
63
+ end
@@ -0,0 +1,69 @@
1
+ RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_SETUP)
2
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+
5
+ class Riot::Situation
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ ##
10
+ # You can handle all padrino applications using instead:
11
+ # Padrino.application
12
+ CLASS_NAME.tap { |app| }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ RIOT_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_CONTROLLER_TEST)
18
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
19
+
20
+ context "!NAME!Controller" do
21
+ context "description here" do
22
+ setup do
23
+ get "/"
24
+ end
25
+
26
+ asserts("the response body") { last_response.body }.equals "Hello World"
27
+ end
28
+ end
29
+ TEST
30
+
31
+ RIOT_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_RAKE)
32
+ require 'rake/testtask'
33
+
34
+ Rake::TestTask.new(:test) do |test|
35
+ test.pattern = '**/*_test.rb'
36
+ test.verbose = true
37
+ end
38
+ TEST
39
+
40
+ RIOT_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_MODEL_TEST)
41
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
42
+
43
+ context "!NAME! Model" do
44
+ context 'can be created' do
45
+ setup do
46
+ @!DNAME! = !NAME!.new
47
+ end
48
+
49
+ asserts("that record is not nil") { !@!DNAME!.nil? }
50
+ end
51
+ end
52
+ TEST
53
+
54
+ def setup_test
55
+ require_dependencies 'riot', :group => 'test'
56
+ insert_test_suite_setup RIOT_SETUP
57
+ create_file destination_root("test/test.rake"), RIOT_RAKE
58
+ end
59
+
60
+ # Generates a controller test given the controllers name
61
+ def generate_controller_test(name)
62
+ riot_contents = RIOT_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
63
+ create_file destination_root("test/controllers/#{name.to_s.underscore}_controller_test.rb"), riot_contents, :skip => true
64
+ end
65
+
66
+ def generate_model_test(name)
67
+ riot_contents = RIOT_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
68
+ create_file destination_root("test/models/#{name.to_s.underscore}_test.rb"), riot_contents, :skip => true
69
+ end
@@ -0,0 +1,66 @@
1
+ RSPEC_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_SETUP)
2
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+
5
+ Spec::Runner.configure do |conf|
6
+ conf.include Rack::Test::Methods
7
+ end
8
+
9
+ def app
10
+ ##
11
+ # You can handle all padrino applications using instead:
12
+ # Padrino.application
13
+ CLASS_NAME.tap { |app| }
14
+ end
15
+ TEST
16
+
17
+ RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
18
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
19
+
20
+ describe "!NAME!Controller" do
21
+ before do
22
+ get "/"
23
+ end
24
+
25
+ it "returns hello world" do
26
+ last_response.body.should == "Hello World"
27
+ end
28
+ end
29
+ TEST
30
+
31
+ RSPEC_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_RAKE)
32
+ require 'spec/rake/spectask'
33
+
34
+ Spec::Rake::SpecTask.new(:spec) do |t|
35
+ t.spec_files = Dir['**/*_spec.rb']
36
+ t.spec_opts = %w(-fs --color)
37
+ end
38
+ TEST
39
+
40
+ RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
41
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
42
+
43
+ describe "!NAME! Model" do
44
+ it 'can be created' do
45
+ @!DNAME! = !NAME!.new
46
+ @!DNAME!.should_not be_nil
47
+ end
48
+ end
49
+ TEST
50
+
51
+ def setup_test
52
+ require_dependencies 'rspec', :require => 'spec', :group => 'test'
53
+ insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
54
+ create_file destination_root("spec/spec.rake"), RSPEC_RAKE
55
+ end
56
+
57
+ # Generates a controller test given the controllers name
58
+ def generate_controller_test(name)
59
+ rspec_contents = RSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
60
+ create_file destination_root("spec/controllers/#{name.to_s.underscore}_controller_spec.rb"), rspec_contents, :skip => true
61
+ end
62
+
63
+ def generate_model_test(name)
64
+ rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
65
+ create_file destination_root("spec/models/#{name.to_s.underscore}_spec.rb"), rspec_contents, :skip => true
66
+ end
@@ -0,0 +1,70 @@
1
+ SHOULDA_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_SETUP)
2
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+
5
+ class Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ ##
10
+ # You can handle all padrino applications using instead:
11
+ # Padrino.application
12
+ CLASS_NAME.tap { |app| }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ SHOULDA_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_CONTROLLER_TEST)
18
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
19
+
20
+ class !NAME!ControllerTest < Test::Unit::TestCase
21
+ context "!NAME!Controller" do
22
+ setup do
23
+ get '/'
24
+ end
25
+
26
+ should "return hello world text" do
27
+ assert_equal "Hello World", last_response.body
28
+ end
29
+ end
30
+ end
31
+ TEST
32
+
33
+ SHOULDA_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_RAKE)
34
+ require 'rake/testtask'
35
+
36
+ Rake::TestTask.new(:test) do |test|
37
+ test.pattern = '**/*_test.rb'
38
+ test.verbose = true
39
+ end
40
+ TEST
41
+
42
+ SHOULDA_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_MODEL_TEST)
43
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
44
+
45
+ class !NAME!ControllerTest < Test::Unit::TestCase
46
+ context "!NAME! Model" do
47
+ should 'construct new instance' do
48
+ @!DNAME! = !NAME!.new
49
+ assert_not_nil @!DNAME!
50
+ end
51
+ end
52
+ end
53
+ TEST
54
+
55
+ def setup_test
56
+ require_dependencies 'shoulda', :group => 'test'
57
+ insert_test_suite_setup SHOULDA_SETUP
58
+ create_file destination_root("test/test.rake"), SHOULDA_RAKE
59
+ end
60
+
61
+ # Generates a controller test given the controllers name
62
+ def generate_controller_test(name)
63
+ shoulda_contents = SHOULDA_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
64
+ create_file destination_root("test/controllers/#{name.to_s.underscore}_controller_test.rb"), shoulda_contents, :skip => true
65
+ end
66
+
67
+ def generate_model_test(name)
68
+ shoulda_contents = SHOULDA_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
69
+ create_file destination_root("test/models/#{name.to_s.underscore}_test.rb"), shoulda_contents, :skip => true
70
+ end
@@ -0,0 +1,63 @@
1
+ TESTSPEC_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_SETUP)
2
+ PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+
5
+ class Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ ##
10
+ # You can handle all padrino applications using instead:
11
+ # Padrino.application
12
+ CLASS_NAME.tap { |app| }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ TESTSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_CONTROLLER_TEST)
18
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
19
+
20
+ context "!NAME!Controller" do
21
+ setup { get('/') }
22
+ specify "returns hello world" do
23
+ last_response.body.should.equal "Hello World"
24
+ end
25
+ end
26
+ TEST
27
+
28
+ TESTSPEC_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_RAKE)
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.pattern = '**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ TEST
36
+
37
+ TESTSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_MODEL_TEST)
38
+ require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
39
+
40
+ context "!NAME! Model" do
41
+ specify 'can be created' do
42
+ @!DNAME! = !NAME!.new
43
+ @!DNAME!.should.not.be.nil
44
+ end
45
+ end
46
+ TEST
47
+
48
+ def setup_test
49
+ require_dependencies 'test-spec', :require => 'test/spec', :group => 'test'
50
+ insert_test_suite_setup TESTSPEC_SETUP
51
+ create_file destination_root("test/test.rake"), TESTSPEC_RAKE
52
+ end
53
+
54
+ # Generates a controller test given the controllers name
55
+ def generate_controller_test(name)
56
+ testspec_contents = TESTSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
57
+ create_file destination_root("test/controllers/#{name.to_s.underscore}_controller_test.rb"), testspec_contents, :skip => true
58
+ end
59
+
60
+ def generate_model_test(name)
61
+ tests_contents = TESTSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
62
+ create_file destination_root("test/models/#{name.to_s.underscore}_test.rb"), tests_contents, :skip => true
63
+ end
@@ -33,11 +33,11 @@ module Padrino
33
33
  check_app_existence(app)
34
34
  @app_name = fetch_app_name(app)
35
35
  @actions = controller_actions(fields)
36
- @controller = name
36
+ @controller = name.to_s.underscore
37
37
  self.behavior = :revoke if options[:destroy]
38
- template "templates/controller.rb.tt", destination_root(app, "controllers", "#{name}.rb")
39
- template "templates/helper.rb.tt", destination_root(app, "helpers", "#{name}_helper.rb")
40
- empty_directory destination_root(app, "/views/#{name}")
38
+ template "templates/controller.rb.tt", destination_root(app, "controllers", "#{name.to_s.underscore}.rb")
39
+ template "templates/helper.rb.tt", destination_root(app, "helpers", "#{name.to_s.underscore}_helper.rb")
40
+ empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
41
41
  include_component_module_for(:test)
42
42
  generate_controller_test(name) if test?
43
43
  else
@@ -3,11 +3,19 @@
3
3
  This file mounts each application within the Padrino project to a specific path.
4
4
  You can mount additional applications using any of these below:
5
5
 
6
- Padrino.mount("blog").to('/blog')
7
- Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
8
- Padrino.mount("blog", :app_file => "/path/to/blog/app.rb").to('/blog')
6
+ Padrino.mount("blog").to('/blog')
7
+ Padrino.mount("blog", :app_class => "BlogApp").to('/blog')
8
+ Padrino.mount("blog", :app_file => "/path/to/blog/app.rb").to('/blog')
9
9
 
10
- Note that mounted apps by default should be placed into 'apps/app_name'.
10
+ You can map also apps to a specified host:
11
+
12
+ Padrino.mount_core("Blog").host("blog.example.org")
13
+ Padrino.mount("Admin").host("admin.example.org")
14
+ Padrino.mount("WebSite").host(/.*\.?example.org/)
15
+ Padrino.mount("Foo").to("/foo").host("bar.example.org")
16
+
17
+ Note 1: that mounted apps by default should be placed into 'apps/app_name'.
18
+ Note 2: if you use host match remember that it's important respect order.
11
19
 
12
20
  By default, this file simply mounts the core app which was generated with this project.
13
21
  However, the mounted core can be modified as needed:
@@ -12,7 +12,7 @@ rescue LoadError
12
12
  Bundler.setup
13
13
  end
14
14
 
15
- Bundler.require(:default, PADRINO_ENV)
15
+ Bundler.require(:default, PADRINO_ENV.to_sym)
16
16
  puts "=> Located #{Padrino.bundle} Gemfile for #{Padrino.env}"
17
17
 
18
18
  Padrino.load!
@@ -28,7 +28,7 @@ module Padrino
28
28
  component_option :orm, "database engine", :aliases => '-d', :choices => [:activerecord, :datamapper, :mongomapper, :mongoid, :sequel, :couchrest], :default => :none
29
29
  component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec, :shoulda, :cucumber, :bacon, :testspec, :riot], :default => :rspec
30
30
  component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr], :default => :none
31
- component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools], :default => :none
31
+ component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools, :extcore], :default => :none
32
32
  component_option :renderer, "template engine", :aliases => '-e', :choices => [:haml, :erb], :default => :haml
33
33
  component_option :stylesheet, "stylesheet engine", :aliases => '-c', :choices => [:less, :sass], :default => :none
34
34
 
@@ -1,4 +1,4 @@
1
- <%= @app_name %>.controllers :<%= @name %> do
1
+ <%= @app_name %>.controllers :<%= @controller %> do
2
2
  # get :index, :map => "/foo/bar" do
3
3
  # session[:foo] = "bar"
4
4
  # render 'index'