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
data/padrino-gen.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-gen}
8
- s.version = "0.9.9"
8
+ s.version = "0.9.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-03-29}
12
+ s.date = %q{2010-04-22}
13
13
  s.default_executable = %q{padrino-gen}
14
14
  s.description = %q{Generators for easily creating and building padrino applications from the console}
15
15
  s.email = %q{padrinorb@gmail.com}
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
  "LICENSE",
24
24
  "README.rdoc",
25
25
  "Rakefile",
26
- "VERSION",
27
26
  "bin/padrino-gen",
28
27
  "lib/padrino-gen.rb",
29
28
  "lib/padrino-gen/generators/actions.rb",
@@ -35,28 +34,29 @@ Gem::Specification.new do |s|
35
34
  "lib/padrino-gen/generators/app/views/layouts/.emptydirectory",
36
35
  "lib/padrino-gen/generators/cli.rb",
37
36
  "lib/padrino-gen/generators/components/actions.rb",
38
- "lib/padrino-gen/generators/components/mocks/mocha_gen.rb",
39
- "lib/padrino-gen/generators/components/mocks/rr_gen.rb",
40
- "lib/padrino-gen/generators/components/orms/activerecord_gen.rb",
41
- "lib/padrino-gen/generators/components/orms/couchrest_gen.rb",
42
- "lib/padrino-gen/generators/components/orms/datamapper_gen.rb",
43
- "lib/padrino-gen/generators/components/orms/mongoid_gen.rb",
44
- "lib/padrino-gen/generators/components/orms/mongomapper_gen.rb",
45
- "lib/padrino-gen/generators/components/orms/sequel_gen.rb",
46
- "lib/padrino-gen/generators/components/renderers/erb_gen.rb",
47
- "lib/padrino-gen/generators/components/renderers/haml_gen.rb",
48
- "lib/padrino-gen/generators/components/scripts/jquery_gen.rb",
49
- "lib/padrino-gen/generators/components/scripts/mootools_gen.rb",
50
- "lib/padrino-gen/generators/components/scripts/prototype_gen.rb",
51
- "lib/padrino-gen/generators/components/scripts/rightjs_gen.rb",
52
- "lib/padrino-gen/generators/components/stylesheets/less_gen.rb",
53
- "lib/padrino-gen/generators/components/stylesheets/sass_gen.rb",
54
- "lib/padrino-gen/generators/components/tests/bacon_test_gen.rb",
55
- "lib/padrino-gen/generators/components/tests/cucumber_test_gen.rb",
56
- "lib/padrino-gen/generators/components/tests/riot_test_gen.rb",
57
- "lib/padrino-gen/generators/components/tests/rspec_test_gen.rb",
58
- "lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb",
59
- "lib/padrino-gen/generators/components/tests/testspec_test_gen.rb",
37
+ "lib/padrino-gen/generators/components/mocks/mocha.rb",
38
+ "lib/padrino-gen/generators/components/mocks/rr.rb",
39
+ "lib/padrino-gen/generators/components/orms/activerecord.rb",
40
+ "lib/padrino-gen/generators/components/orms/couchrest.rb",
41
+ "lib/padrino-gen/generators/components/orms/datamapper.rb",
42
+ "lib/padrino-gen/generators/components/orms/mongoid.rb",
43
+ "lib/padrino-gen/generators/components/orms/mongomapper.rb",
44
+ "lib/padrino-gen/generators/components/orms/sequel.rb",
45
+ "lib/padrino-gen/generators/components/renderers/erb.rb",
46
+ "lib/padrino-gen/generators/components/renderers/haml.rb",
47
+ "lib/padrino-gen/generators/components/scripts/extcore.rb",
48
+ "lib/padrino-gen/generators/components/scripts/jquery.rb",
49
+ "lib/padrino-gen/generators/components/scripts/mootools.rb",
50
+ "lib/padrino-gen/generators/components/scripts/prototype.rb",
51
+ "lib/padrino-gen/generators/components/scripts/rightjs.rb",
52
+ "lib/padrino-gen/generators/components/stylesheets/less.rb",
53
+ "lib/padrino-gen/generators/components/stylesheets/sass.rb",
54
+ "lib/padrino-gen/generators/components/tests/bacon.rb",
55
+ "lib/padrino-gen/generators/components/tests/cucumber.rb",
56
+ "lib/padrino-gen/generators/components/tests/riot.rb",
57
+ "lib/padrino-gen/generators/components/tests/rspec.rb",
58
+ "lib/padrino-gen/generators/components/tests/shoulda.rb",
59
+ "lib/padrino-gen/generators/components/tests/testspec.rb",
60
60
  "lib/padrino-gen/generators/controller.rb",
61
61
  "lib/padrino-gen/generators/mailer.rb",
62
62
  "lib/padrino-gen/generators/migration.rb",
@@ -76,6 +76,7 @@ Gem::Specification.new do |s|
76
76
  "lib/padrino-gen/generators/templates/helper.rb.tt",
77
77
  "lib/padrino-gen/generators/templates/mailer.rb.tt",
78
78
  "lib/padrino-gen/generators/templates/mailer_initializer.rb.tt",
79
+ "lib/padrino-gen/generators/templates/scripts/ext-core.js",
79
80
  "lib/padrino-gen/generators/templates/scripts/jquery.js",
80
81
  "lib/padrino-gen/generators/templates/scripts/lowpro.js",
81
82
  "lib/padrino-gen/generators/templates/scripts/mootools-core.js",
@@ -85,6 +86,7 @@ Gem::Specification.new do |s|
85
86
  "lib/padrino-gen/padrino-tasks/datamapper.rb",
86
87
  "lib/padrino-gen/padrino-tasks/mongomapper.rb",
87
88
  "lib/padrino-gen/padrino-tasks/seed.rb",
89
+ "lib/padrino-gen/padrino-tasks/sequel.rb",
88
90
  "padrino-gen.gemspec",
89
91
  "test/helper.rb",
90
92
  "test/test_app_generator.rb",
@@ -108,7 +110,7 @@ Gem::Specification.new do |s|
108
110
  s.specification_version = 3
109
111
 
110
112
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
111
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.9"])
113
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.10"])
112
114
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
113
115
  s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
114
116
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
@@ -116,7 +118,7 @@ Gem::Specification.new do |s|
116
118
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
117
119
  s.add_development_dependency(%q<fakeweb>, [">= 1.2.3"])
118
120
  else
119
- s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
121
+ s.add_dependency(%q<padrino-core>, ["= 0.9.10"])
120
122
  s.add_dependency(%q<haml>, [">= 2.2.1"])
121
123
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
122
124
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -125,7 +127,7 @@ Gem::Specification.new do |s|
125
127
  s.add_dependency(%q<fakeweb>, [">= 1.2.3"])
126
128
  end
127
129
  else
128
- s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
130
+ s.add_dependency(%q<padrino-core>, ["= 0.9.10"])
129
131
  s.add_dependency(%q<haml>, [">= 2.2.1"])
130
132
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
131
133
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
data/test/helper.rb CHANGED
@@ -32,6 +32,11 @@ class Test::Unit::TestCase
32
32
  Time.stubs(:now).returns(time)
33
33
  return time
34
34
  end
35
+
36
+ # generate(:controller, 'DemoItems', '-r=/tmp/sample_project')
37
+ def generate(name, *params)
38
+ "Padrino::Generators::#{name.to_s.camelize}".constantize.start(params)
39
+ end
35
40
 
36
41
  # assert_has_tag(:h1, :content => "yellow") { "<h1>yellow</h1>" }
37
42
  # In this case, block is the html to evaluate
@@ -1,27 +1,20 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require 'thor/group'
3
- require 'fakeweb'
4
2
 
5
3
  class TestAppGenerator < Test::Unit::TestCase
6
4
  def setup
7
- FakeWeb.allow_net_connect = false
8
5
  `rm -rf /tmp/sample_project`
9
- @project = Padrino::Generators::Project.dup
10
- @app = Padrino::Generators::App.dup
11
- @cont_gen = Padrino::Generators::Controller.dup
12
- @mail_gen = Padrino::Generators::Mailer.dup
13
6
  end
14
7
 
15
8
  context 'the app generator' do
16
9
  should "fail outside app root" do
17
- output = silence_logger { @app.start(['demo', '-r=/tmp']) }
10
+ output = silence_logger { generate(:app, 'demo_root', '-r=/tmp') }
18
11
  assert_match(/not at the root/, output)
19
- assert_no_file_exists('/tmp/demo')
12
+ assert_no_file_exists('/tmp/demo_root')
20
13
  end
21
14
 
22
15
  should "create correctly a new padrino application" do
23
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp']) } }
24
- assert_nothing_raised { silence_logger { @app.start(['demo', '--root=/tmp/sample_project']) } }
16
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp') } }
17
+ assert_nothing_raised { silence_logger { generate(:app, 'demo', '--root=/tmp/sample_project') } }
25
18
  assert_file_exists('/tmp/sample_project')
26
19
  assert_file_exists('/tmp/sample_project/demo')
27
20
  assert_file_exists('/tmp/sample_project/demo/app.rb')
@@ -34,23 +27,22 @@ class TestAppGenerator < Test::Unit::TestCase
34
27
  end
35
28
 
36
29
  should "correctly create a new controller inside a padrino application" do
37
- silence_logger { @project.start(['sample_project', '--root=/tmp']) }
38
- silence_logger { @app.start(['demo', '--root=/tmp/sample_project']) }
39
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project', '-a=demo']) }
30
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp') }
31
+ silence_logger { generate(:app, 'demo', '--root=/tmp/sample_project') }
32
+ silence_logger { generate(:controller, 'demo_items', '-r=/tmp/sample_project', '-a=demo') }
40
33
  assert_match_in_file(/Demo.controllers :demo_items do/m, '/tmp/sample_project/demo/controllers/demo_items.rb')
41
34
  assert_match_in_file(/Demo.helpers do/m, '/tmp/sample_project/demo/helpers/demo_items_helper.rb')
42
35
  assert_file_exists('/tmp/sample_project/demo/views/demo_items')
43
36
  end
44
37
 
45
38
  should "correctly create a new mailer inside a padrino application" do
46
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
47
- silence_logger { @app.start(['demo', '--root=/tmp/sample_project']) }
48
- silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project', '-a=demo']) }
39
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
40
+ silence_logger { generate(:app, 'demo', '--root=/tmp/sample_project') }
41
+ silence_logger { generate(:mailer, 'demo', '-r=/tmp/sample_project', '-a=demo') }
49
42
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/demo/mailers/demo_mailer.rb')
50
43
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/lib/mailer.rb')
51
44
  assert_match_in_file(/register MailerInitializer/,'/tmp/sample_project/demo/app.rb')
52
45
  assert_file_exists('/tmp/sample_project/demo/views/demo_mailer')
53
46
  end
54
-
55
47
  end
56
- end
48
+ end
data/test/test_cli.rb CHANGED
@@ -4,20 +4,18 @@ require 'padrino-gen/generators/cli'
4
4
  class TestCli < Test::Unit::TestCase
5
5
  def setup
6
6
  `rm -rf /tmp/sample_project`
7
- @cli = Padrino::Generators::Cli.dup
8
- @project = Padrino::Generators::Project.dup
9
7
  end
10
8
 
11
9
  context 'the cli' do
12
10
 
13
11
  should "fail without arguments" do
14
- output = silence_logger { @cli.start }
12
+ output = silence_logger { generate(:cli) }
15
13
  assert_match "Please specify generator to use", output
16
14
  end
17
15
 
18
16
  should "work correctly if we have a project" do
19
- silence_logger { @project.start(['sample_project', '--root=/tmp']) }
20
- assert_nothing_raised { silence_logger { @cli.start(['--root=/tmp/sample_project']) } }
17
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp') }
18
+ assert_nothing_raised { silence_logger { generate(:cli, '--root=/tmp/sample_project') } }
21
19
  end
22
20
  end
23
- end
21
+ end
@@ -1,10 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require 'thor/group'
3
2
 
4
3
  class TestControllerGenerator < Test::Unit::TestCase
5
4
  def setup
6
- @project = Padrino::Generators::Project.dup
7
- @cont_gen = Padrino::Generators::Controller.dup
8
5
  @controller_path = '/tmp/sample_project/app/controllers/demo_items.rb'
9
6
  @controller_test_path = '/tmp/sample_project/test/controllers/demo_items_controller_test.rb'
10
7
  `rm -rf /tmp/sample_project`
@@ -12,14 +9,14 @@ class TestControllerGenerator < Test::Unit::TestCase
12
9
 
13
10
  context 'the controller generator' do
14
11
  should "fail outside app root" do
15
- output = silence_logger { @cont_gen.start(['demo', '-r=/tmp']) }
12
+ output = silence_logger { generate(:controller, 'demo', '-r=/tmp') }
16
13
  assert_match(/not at the root/, output)
17
14
  assert_no_file_exists('/tmp/app/controllers/demo.rb')
18
15
  end
19
16
 
20
17
  should 'not fail if we don\'t have test component' do
21
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--test=none']) }
22
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
18
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=none') }
19
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
23
20
  assert_match_in_file(/SampleProject.controllers :demo_items do/m, @controller_path)
24
21
  assert_match_in_file(/SampleProject.helpers do/m, '/tmp/sample_project/app/helpers/demo_items_helper.rb')
25
22
  assert_file_exists('/tmp/sample_project/app/views/demo_items')
@@ -27,74 +24,87 @@ class TestControllerGenerator < Test::Unit::TestCase
27
24
  end
28
25
 
29
26
  should "generate controller within existing application" do
30
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
31
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
27
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
28
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
32
29
  assert_match_in_file(/SampleProject.controllers :demo_items do/m, @controller_path)
33
30
  assert_match_in_file(/SampleProject.helpers do/m, '/tmp/sample_project/app/helpers/demo_items_helper.rb')
34
31
  assert_file_exists('/tmp/sample_project/app/views/demo_items')
35
32
  end
36
33
 
37
34
  should "generate controller test for bacon" do
38
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
39
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
35
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
36
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
40
37
  assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path)
41
38
  end
42
39
 
43
40
  should "generate controller test for riot" do
44
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=riot']) }
45
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
41
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=riot') }
42
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
46
43
  assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path)
47
44
  end
48
45
 
49
46
  should "generate controller test for testspec" do
50
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=testspec']) }
51
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
47
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=testspec') }
48
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
52
49
  assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path)
53
50
  end
54
51
 
55
52
  should "generate controller test for rspec" do
56
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=rspec']) }
57
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
53
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=rspec') }
54
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
58
55
  assert_match_in_file(/describe "DemoItemsController" do/m, '/tmp/sample_project/spec/controllers/demo_items_controller_spec.rb')
59
56
  end
60
57
 
61
58
  should "generate controller test for shoulda" do
62
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=shoulda']) }
63
- silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project']) }
59
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=shoulda') }
60
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
64
61
  expected_pattern = /class DemoItemsControllerTest < Test::Unit::TestCase/m
65
62
  assert_match_in_file(expected_pattern, @controller_test_path)
63
+ assert_file_exists('/tmp/sample_project/test/controllers/demo_items_controller_test.rb')
66
64
  end
67
65
 
68
- # Controller action generation
66
+ should "generate controller test for cucumber" do
67
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=cucumber') }
68
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
69
+ assert_match_in_file(/describe "DemoItemsController" do/m, '/tmp/sample_project/spec/controllers/demo_items_controller_spec.rb')
70
+ assert_match_in_file(/Capybara.app = /, '/tmp/sample_project/features/support/env.rb')
71
+ end
69
72
 
70
- should "generate actions for get:test post:yada" do
71
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=shoulda'])}
72
- silence_logger { @cont_gen.start(['demo_items', "get:test", "post:yada",'-r=/tmp/sample_project']) }
73
- assert_match_in_file(/get :test do\n end\n/m,@controller_path)
74
- assert_match_in_file(/post :yada do\n end\n/m,@controller_path)
73
+ should "correctly generate file names" do
74
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=rspec') }
75
+ silence_logger { generate(:controller, 'DemoItems', '-r=/tmp/sample_project') }
76
+ assert_file_exists('/tmp/sample_project/app/views/demo_items')
77
+ assert_file_exists('/tmp/sample_project/app/controllers/demo_items.rb')
78
+ assert_file_exists('/tmp/sample_project/app/helpers/demo_items_helper.rb')
79
+ assert_file_exists('/tmp/sample_project/spec/controllers/demo_items_controller_spec.rb')
75
80
  end
76
81
 
82
+ # Controller action generation
83
+ should "generate actions for get:test post:yada" do
84
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=shoulda') }
85
+ silence_logger { generate(:controller, 'demo_items', "get:test", "post:yada",'-r=/tmp/sample_project') }
86
+ assert_match_in_file(/get :test do\n end\n/m, @controller_path)
87
+ assert_match_in_file(/post :yada do\n end\n/m, @controller_path)
88
+ end
77
89
  end
78
90
 
79
91
  context "the controller destroy option" do
80
-
81
92
  should "destroy controller files" do
82
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon'])}
83
- silence_logger { @cont_gen.start(['demo_items','-r=/tmp/sample_project']) }
84
- silence_logger { @cont_gen.start(['demo_items','-r=/tmp/sample_project','-d'])}
93
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
94
+ silence_logger { generate(:controller, 'demo_items','-r=/tmp/sample_project') }
95
+ silence_logger { generate(:controller, 'demo_items','-r=/tmp/sample_project','-d') }
85
96
  assert_no_file_exists(@controller_path)
86
97
  assert_no_file_exists(@controller_test_path)
87
98
  assert_no_file_exists('/tmp/sample_project/app/helpers/demo_items_helper.rb')
88
99
  end
89
100
 
90
101
  should "destroy controller files with rspec" do
91
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=rspec'])}
92
- silence_logger { @cont_gen.start(['demo_items','-r=/tmp/sample_project']) }
93
- silence_logger { @cont_gen.start(['demo_items','-r=/tmp/sample_project','-d'])}
102
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=rspec') }
103
+ silence_logger { generate(:controller, 'demo_items','-r=/tmp/sample_project') }
104
+ silence_logger { generate(:controller, 'demo_items','-r=/tmp/sample_project','-d') }
94
105
  assert_no_file_exists(@controller_path)
95
106
  assert_no_file_exists('/tmp/sample_project/app/helpers/demo_items_helper.rb')
96
107
  assert_no_file_exists('/tmp/sample_project/spec/controllers/demo_items_controller_spec.rb')
97
108
  end
98
-
99
109
  end
100
- end
110
+ end
@@ -1,23 +1,20 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require 'thor/group'
3
2
 
4
3
  class TestMailerGenerator < Test::Unit::TestCase
5
4
  def setup
6
- @project = Padrino::Generators::Project.dup
7
- @mail_gen = Padrino::Generators::Mailer.dup
8
5
  `rm -rf /tmp/sample_project`
9
6
  end
10
7
 
11
8
  context 'the mailer generator' do
12
9
  should "fail outside app root" do
13
- output = silence_logger { @mail_gen.start(['demo', '-r=/tmp']) }
10
+ output = silence_logger { generate(:mailer, 'demo', '-r=/tmp') }
14
11
  assert_match(/not at the root/, output)
15
12
  assert_no_file_exists('/tmp/app/mailers/demo_mailer.rb')
16
13
  end
17
14
 
18
15
  should "support generating a new mailer extended from base" do
19
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
20
- silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project']) }
16
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
17
+ silence_logger { generate(:mailer, 'demo', '-r=/tmp/sample_project') }
21
18
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/app/mailers/demo_mailer.rb')
22
19
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/lib/mailer.rb')
23
20
  assert_match_in_file(/register MailerInitializer/m, '/tmp/sample_project/app/app.rb')
@@ -25,33 +22,30 @@ class TestMailerGenerator < Test::Unit::TestCase
25
22
  end
26
23
 
27
24
  should "support generating a new mailer extended from base with long name" do
28
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
29
- silence_logger { @mail_gen.start(['user_notice', '-r=/tmp/sample_project']) }
25
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
26
+ silence_logger { generate(:mailer, 'user_notice', '-r=/tmp/sample_project') }
30
27
  assert_match_in_file(/class UserNoticeMailer/m, '/tmp/sample_project/app/mailers/user_notice_mailer.rb')
31
28
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/lib/mailer.rb')
32
29
  assert_file_exists('/tmp/sample_project/app/views/user_notice_mailer')
33
30
  end
34
31
 
35
32
  should "support generating a new mailer extended from base with capitalized name" do
36
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
37
- silence_logger { @mail_gen.start(['DEMO', '-r=/tmp/sample_project']) }
33
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
34
+ silence_logger { generate(:mailer, 'DEMO', '-r=/tmp/sample_project') }
38
35
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/app/mailers/demo_mailer.rb')
39
36
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/lib/mailer.rb')
40
37
  assert_file_exists('/tmp/sample_project/app/views/demo_mailer')
41
38
  end
42
-
43
39
  end
44
40
 
45
41
  context "the mailer destroy option" do
46
-
47
42
  should "destroy mailer file" do
48
- silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
49
- silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project']) }
50
- silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project','-d']) }
43
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=none', '-t=bacon') }
44
+ silence_logger { generate(:mailer, 'demo', '-r=/tmp/sample_project') }
45
+ silence_logger { generate(:mailer, 'demo', '-r=/tmp/sample_project','-d') }
51
46
  assert_no_dir_exists('/tmp/sample_project/app/views/demo_mailer')
52
47
  assert_no_file_exists('/tmp/sample_project/app/mailers/demo_mailer.rb')
53
48
  assert_no_file_exists('/tmp/sample_project/lib/mailer.rb')
54
49
  end
55
50
  end
56
-
57
- end
51
+ end