padrino-gen 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/padrino-gen.rb +1 -1
  3. data/lib/padrino-gen/command.rb +1 -1
  4. data/lib/padrino-gen/generators/app.rb +1 -1
  5. data/lib/padrino-gen/generators/app/app.rb.tt +1 -1
  6. data/lib/padrino-gen/generators/cli.rb +1 -1
  7. data/lib/padrino-gen/generators/components/actions.rb +1 -1
  8. data/lib/padrino-gen/generators/components/mocks/mocha.rb +1 -1
  9. data/lib/padrino-gen/generators/components/mocks/rr.rb +1 -1
  10. data/lib/padrino-gen/generators/components/orms/sequel.rb +5 -5
  11. data/lib/padrino-gen/generators/components/renderers/erb.rb +1 -1
  12. data/lib/padrino-gen/generators/components/renderers/haml.rb +1 -1
  13. data/lib/padrino-gen/generators/components/renderers/liquid.rb +1 -1
  14. data/lib/padrino-gen/generators/components/renderers/slim.rb +1 -1
  15. data/lib/padrino-gen/generators/components/scripts/dojo.rb +1 -1
  16. data/lib/padrino-gen/generators/components/scripts/extcore.rb +1 -1
  17. data/lib/padrino-gen/generators/components/scripts/jquery.rb +1 -1
  18. data/lib/padrino-gen/generators/components/scripts/mootools.rb +1 -1
  19. data/lib/padrino-gen/generators/components/scripts/prototype.rb +1 -1
  20. data/lib/padrino-gen/generators/components/scripts/rightjs.rb +1 -1
  21. data/lib/padrino-gen/generators/components/stylesheets/compass.rb +1 -1
  22. data/lib/padrino-gen/generators/components/stylesheets/compass/application.scss +1 -1
  23. data/lib/padrino-gen/generators/components/stylesheets/compass/partials/_base.scss +1 -1
  24. data/lib/padrino-gen/generators/components/stylesheets/less.rb +1 -1
  25. data/lib/padrino-gen/generators/components/stylesheets/sass.rb +1 -1
  26. data/lib/padrino-gen/generators/components/tests/bacon.rb +3 -1
  27. data/lib/padrino-gen/generators/components/tests/riot.rb +3 -1
  28. data/lib/padrino-gen/generators/components/tests/shoulda.rb +3 -1
  29. data/lib/padrino-gen/generators/components/tests/testspec.rb +3 -1
  30. data/lib/padrino-gen/generators/controller.rb +1 -1
  31. data/lib/padrino-gen/generators/mailer.rb +1 -1
  32. data/lib/padrino-gen/generators/migration.rb +1 -1
  33. data/lib/padrino-gen/generators/plugin.rb +1 -1
  34. data/lib/padrino-gen/generators/project/config/boot.rb +1 -1
  35. data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
  36. data/lib/padrino-gen/generators/templates/helper.rb.tt +1 -1
  37. data/lib/padrino-gen/generators/templates/initializer.rb.tt +1 -1
  38. data/lib/padrino-gen/generators/templates/mailer.rb.tt +1 -1
  39. data/lib/padrino-gen/padrino-tasks/seed.rb +1 -1
  40. data/lib/padrino-gen/padrino-tasks/sequel.rb +1 -1
  41. data/test/fixtures/admin_template.rb +1 -1
  42. data/test/fixtures/git_template.rb +1 -1
  43. data/test/fixtures/plugin_template.rb +1 -1
  44. data/test/fixtures/rake_template.rb +1 -1
  45. data/test/helper.rb +2 -2
  46. data/test/test_cli.rb +1 -1
  47. data/test/test_controller_generator.rb +4 -0
  48. data/test/test_generator.rb +1 -1
  49. data/test/test_mailer_generator.rb +1 -1
  50. data/test/test_migration_generator.rb +1 -1
  51. data/test/test_model_generator.rb +54 -0
  52. metadata +30 -3
data/README.rdoc CHANGED
@@ -160,4 +160,4 @@ To learn more about the mailer generator, check out the guide to
160
160
 
161
161
  == Copyright
162
162
 
163
- Copyright (c) 2011 Padrino. See LICENSE for details.
163
+ Copyright (c) 2011 Padrino. See LICENSE for details.
data/lib/padrino-gen.rb CHANGED
@@ -74,4 +74,4 @@ Padrino::Generators.load_paths << Dir[File.dirname(__FILE__) + '/padrino-gen/gen
74
74
  ##
75
75
  # We add our tasks to padrino-core
76
76
  #
77
- Padrino::Tasks.files << Dir[File.dirname(__FILE__) + "/padrino-gen/padrino-tasks/**/*.rb"]
77
+ Padrino::Tasks.files << Dir[File.dirname(__FILE__) + "/padrino-gen/padrino-tasks/**/*.rb"]
@@ -9,4 +9,4 @@ module Padrino
9
9
  @_padrino_gen_bin ||= [Padrino.ruby_command, File.expand_path("../../../bin/padrino-gen", __FILE__)]
10
10
  args.empty? ? @_padrino_gen_bin : system(args.unshift(@_padrino_gen_bin).join(" "))
11
11
  end
12
- end # Padrino
12
+ end # Padrino
@@ -51,4 +51,4 @@ module Padrino
51
51
  end
52
52
  end # App
53
53
  end # Generators
54
- end # Padrino
54
+ end # Padrino
@@ -56,4 +56,4 @@ class <%= @app_name %> < Padrino::Application
56
56
  # render 'errors/505'
57
57
  # end
58
58
  #
59
- end
59
+ end
@@ -50,4 +50,4 @@ module Padrino
50
50
  end
51
51
  end # Cli
52
52
  end # Generators
53
- end # Padrino
53
+ end # Padrino
@@ -117,4 +117,4 @@ module Padrino
117
117
  end # Actions
118
118
  end # Components
119
119
  end # Generators
120
- end # Padrino
120
+ end # Padrino
@@ -6,4 +6,4 @@ def setup_mock
6
6
  else
7
7
  insert_mocking_include "Mocha::API"
8
8
  end
9
- end
9
+ end
@@ -8,4 +8,4 @@ def setup_mock
8
8
  else
9
9
  insert_mocking_include "RR::Adapters::RRMethods", :path => "test/test_config.rb"
10
10
  end
11
- end
11
+ end
@@ -13,11 +13,11 @@ def setup_orm
13
13
  db = @app_name.underscore
14
14
  require_dependencies 'sequel'
15
15
  require_dependencies case options[:adapter]
16
- when 'mysql'
17
- sequel.gsub!(/!DB_DEVELOPMENT!/, "\"mysql://localhost/#{db}_development\"")
18
- sequel.gsub!(/!DB_PRODUCTION!/, "\"mysql://localhost/#{db}_production\"")
19
- sequel.gsub!(/!DB_TEST!/,"\"mysql://localhost/#{db}_test\"")
20
- 'mysql'
16
+ when 'mysql', 'mysql2'
17
+ sequel.gsub!(/!DB_DEVELOPMENT!/, "\"#{options[:adapter]}://localhost/#{db}_development\"")
18
+ sequel.gsub!(/!DB_PRODUCTION!/, "\"#{options[:adapter]}://localhost/#{db}_production\"")
19
+ sequel.gsub!(/!DB_TEST!/,"\"#{options[:adapter]}://localhost/#{db}_test\"")
20
+ options[:adapter]
21
21
  when 'postgres'
22
22
  sequel.gsub!(/!DB_DEVELOPMENT!/, "\"postgres://localhost/#{db}_development\"")
23
23
  sequel.gsub!(/!DB_PRODUCTION!/, "\"postgres://localhost/#{db}_production\"")
@@ -1,3 +1,3 @@
1
1
  def setup_renderer
2
2
  require_dependencies 'erubis', :version => "~> 2.7.0"
3
- end
3
+ end
@@ -1,3 +1,3 @@
1
1
  def setup_renderer
2
2
  require_dependencies 'haml'
3
- end
3
+ end
@@ -1,4 +1,4 @@
1
1
  def setup_renderer
2
2
  require_dependencies 'liquid', :version => "= 2.1.2"
3
3
  require_dependencies 'liquify'
4
- end
4
+ end
@@ -1,3 +1,3 @@
1
1
  def setup_renderer
2
2
  require_dependencies 'slim'
3
- end
3
+ end
@@ -7,4 +7,4 @@ def setup_script
7
7
  copy_file('templates/static/ujs/dojo.js', destination_root("/public/javascripts/dojo-ujs.js"))
8
8
  end
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
- end
10
+ end
@@ -7,4 +7,4 @@ def setup_script
7
7
  copy_file('templates/static/ujs/ext.js', destination_root("/public/javascripts/ext-ujs.js"))
8
8
  end
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
- end
10
+ end
@@ -7,4 +7,4 @@ def setup_script
7
7
  copy_file('templates/static/ujs/jquery.js', destination_root("/public/javascripts/jquery-ujs.js"))
8
8
  end
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
- end
10
+ end
@@ -7,4 +7,4 @@ def setup_script
7
7
  copy_file('templates/static/ujs/mootools.js', destination_root("/public/javascripts/mootools-ujs.js"))
8
8
  end
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
- end
10
+ end
@@ -9,4 +9,4 @@ def setup_script
9
9
  copy_file('templates/static/ujs/prototype.js', destination_root("/public/javascripts/prototype-ujs.js"))
10
10
  end
11
11
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
12
- end
12
+ end
@@ -7,4 +7,4 @@ def setup_script
7
7
  copy_file('templates/static/ujs/right.js', destination_root("/public/javascripts/right-ujs.js"))
8
8
  end
9
9
  create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
10
- end
10
+ end
@@ -36,4 +36,4 @@ def setup_stylesheet
36
36
  inject_into_file destination_root('/app/app.rb'), COMPASS_REGISTER, :after => "register Padrino::Helpers\n"
37
37
 
38
38
  directory "components/stylesheets/compass/", destination_root('/app/stylesheets')
39
- end
39
+ end
@@ -40,4 +40,4 @@ form.bp {
40
40
  #sidebar {
41
41
  @include column(3); }
42
42
  #content {
43
- @include column(21, true); } }
43
+ @include column(21, true); } }
@@ -7,4 +7,4 @@ $blueprint-grid-margin: 10px;
7
7
 
8
8
  // Use this to calculate the width based on the total width.
9
9
  // Or you can set !blueprint_grid_width to a fixed value and unset !blueprint_container_size -- it will be calculated for you.
10
- $blueprint-grid-width: ($blueprint-container-size + $blueprint-grid-margin) / $blueprint-grid-columns - $blueprint-grid-margin;
10
+ $blueprint-grid-width: ($blueprint-container-size + $blueprint-grid-margin) / $blueprint-grid-columns - $blueprint-grid-margin;
@@ -19,4 +19,4 @@ def setup_stylesheet
19
19
  require_dependencies 'less', 'rack-less'
20
20
  initializer :less, LESS_INIT
21
21
  empty_directory destination_root('/app/stylesheets')
22
- end
22
+ end
@@ -12,4 +12,4 @@ def setup_stylesheet
12
12
  require_dependencies 'sass'
13
13
  initializer :sass, SASS_INIT.chomp
14
14
  empty_directory destination_root('/app/stylesheets')
15
- end
15
+ end
@@ -42,7 +42,7 @@ task 'test' => test_tasks.map { |f| "test:\#{f}" }
42
42
  TEST
43
43
 
44
44
  BACON_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_MODEL_TEST)
45
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
45
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
46
46
 
47
47
  describe "!NAME! Model" do
48
48
  it 'can be created' do
@@ -69,6 +69,8 @@ end
69
69
 
70
70
  def generate_model_test(name)
71
71
  bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
72
+ path = options[:app] == '.' ? '/..' : '/../..'
73
+ bacon_contents.gsub!(/!PATH!/,path)
72
74
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
73
75
  create_file destination_root(model_test_path), bacon_contents, :skip => true
74
76
  end
@@ -66,7 +66,7 @@ task 'test' => test_tasks.map { |f| "test:\#{f}" }
66
66
  TEST
67
67
 
68
68
  RIOT_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_MODEL_TEST)
69
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
69
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
70
70
 
71
71
  context "!NAME! Model" do
72
72
  context 'can be created' do
@@ -95,6 +95,8 @@ end
95
95
 
96
96
  def generate_model_test(name)
97
97
  riot_contents = RIOT_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize)
98
+ path = options[:app] == '.' ? '/..' : '/../..'
99
+ riot_contents.gsub!(/!PATH!/,path)
98
100
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
99
101
  create_file destination_root(model_test_path), riot_contents, :skip => true
100
102
  end
@@ -47,7 +47,7 @@ task 'test' => test_tasks.map { |f| "test:\#{f}" }
47
47
  TEST
48
48
 
49
49
  SHOULDA_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_MODEL_TEST)
50
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
50
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
51
51
 
52
52
  class !NAME!Test < Test::Unit::TestCase
53
53
  context "!NAME! Model" do
@@ -78,6 +78,8 @@ end
78
78
 
79
79
  def generate_model_test(name)
80
80
  shoulda_contents = SHOULDA_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
81
+ path = options[:app] == '.' ? '/..' : '/../..'
82
+ shoulda_contents.gsub!(/!PATH!/,path)
81
83
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
82
84
  create_file destination_root(model_test_path), shoulda_contents, :skip => true
83
85
  end
@@ -42,7 +42,7 @@ task 'test' => test_tasks.map { |f| "test:\#{f}" }
42
42
  TEST
43
43
 
44
44
  TESTSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTSPEC_MODEL_TEST)
45
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
45
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
46
46
 
47
47
  context "!NAME! Model" do
48
48
  specify 'can be created' do
@@ -68,6 +68,8 @@ end
68
68
 
69
69
  def generate_model_test(name)
70
70
  tests_contents = TESTSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
71
+ path = options[:app] == '.' ? '/..' : '/../..'
72
+ tests_contents.gsub!(/!PATH!/,path)
71
73
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
72
74
  create_file destination_root(model_test_path), tests_contents, :skip => true
73
75
  end
@@ -46,4 +46,4 @@ module Padrino
46
46
  end
47
47
  end # Controller
48
48
  end # Generators
49
- end # Padrino
49
+ end # Padrino
@@ -44,4 +44,4 @@ module Padrino
44
44
  end
45
45
  end # Mailer
46
46
  end # Generators
47
- end # Padrino
47
+ end # Padrino
@@ -41,4 +41,4 @@ module Padrino
41
41
  end
42
42
  end # Migration
43
43
  end # Generators
44
- end # Padrino
44
+ end # Padrino
@@ -54,4 +54,4 @@ module Padrino
54
54
  end
55
55
  end # Plugins
56
56
  end # Generators
57
- end # Padrino
57
+ end # Padrino
@@ -26,4 +26,4 @@ end
26
26
  Padrino.after_load do
27
27
  end
28
28
 
29
- Padrino.load!
29
+ Padrino.load!
@@ -19,4 +19,4 @@
19
19
  # end
20
20
 
21
21
  <%= @actions %>
22
- end
22
+ end
@@ -4,4 +4,4 @@
4
4
  # def simple_helper_method
5
5
  # ...
6
6
  # end
7
- end
7
+ end
@@ -2,4 +2,4 @@ module <%= "#{@_init_name.to_s.camelize}Initializer" %>
2
2
  def self.registered(app)
3
3
  <%= @_init_data %>
4
4
  end
5
- end
5
+ end
@@ -45,4 +45,4 @@
45
45
 
46
46
  <%- end -%>
47
47
  <%- end -%>
48
- end
48
+ end
@@ -2,4 +2,4 @@ desc 'Load the seed data from db/seeds.rb'
2
2
  task :seed => :environment do
3
3
  seed_file = Padrino.root('db', 'seeds.rb')
4
4
  load(seed_file) if File.exist?(seed_file)
5
- end
5
+ end
@@ -34,4 +34,4 @@ if defined?(Sequel)
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -4,4 +4,4 @@ generate :model, "post title:string body:text"
4
4
  rake "ar:create"
5
5
  generate :admin
6
6
  rake "ar:migrate"
7
- generate :admin_page, "post"
7
+ generate :admin_page, "post"
@@ -1,4 +1,4 @@
1
1
  project :test => :rspec, :orm => :activerecord
2
2
  git :init
3
3
  git :add, "."
4
- git :commit, "hello"
4
+ git :commit, "hello"
@@ -10,4 +10,4 @@ HOPTOAD = <<-HOPTOAD
10
10
  HOPTOAD
11
11
  require_dependencies 'rack_hoptoad', :require => 'rack/hoptoad'
12
12
  initializer :hoptoad,HOPTOAD
13
- inject_into_file destination_root('/app/app.rb')," enable :raise_errors\n", :after => "configure do\n"
13
+ inject_into_file destination_root('/app/app.rb')," enable :raise_errors\n", :after => "configure do\n"
@@ -6,4 +6,4 @@ project :test => :shoulda, :orm => :activerecord
6
6
  # }
7
7
  # end
8
8
  # RAKE
9
- rake "custom"
9
+ rake "custom"
data/test/helper.rb CHANGED
@@ -147,8 +147,8 @@ end
147
147
 
148
148
  module Webrat
149
149
  module Logging
150
- def logger # :nodoc:
150
+ def logger # # @private
151
151
  @logger = nil
152
152
  end
153
153
  end
154
- end
154
+ end
data/test/test_cli.rb CHANGED
@@ -23,4 +23,4 @@ class TestCli < Test::Unit::TestCase
23
23
  assert_nothing_raised { silence_logger { generate(:cli, "--root=#{@apptmp}/sample_project") } }
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -59,6 +59,7 @@ class TestControllerGenerator < Test::Unit::TestCase
59
59
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
60
60
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
61
61
  silence_logger { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
62
+ assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
62
63
  assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
63
64
  end
64
65
 
@@ -66,6 +67,7 @@ class TestControllerGenerator < Test::Unit::TestCase
66
67
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot') }
67
68
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
68
69
  silence_logger { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
70
+ assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
69
71
  assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
70
72
  end
71
73
 
@@ -73,6 +75,7 @@ class TestControllerGenerator < Test::Unit::TestCase
73
75
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec') }
74
76
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
75
77
  silence_logger { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
78
+ assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
76
79
  assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
77
80
  end
78
81
 
@@ -89,6 +92,7 @@ class TestControllerGenerator < Test::Unit::TestCase
89
92
  silence_logger { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
90
93
  expected_pattern = /class DemoItemsControllerTest < Test::Unit::TestCase/m
91
94
  assert_match_in_file(expected_pattern, @controller_test_path.gsub('app','subby'))
95
+ assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
92
96
  assert_file_exists("#{@apptmp}/sample_project/test/subby/controllers/demo_items_controller_test.rb")
93
97
  end
94
98
 
@@ -11,4 +11,4 @@ class TestGenerator < Test::Unit::TestCase
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -66,4 +66,4 @@ class TestMailerGenerator < Test::Unit::TestCase
66
66
  assert_no_file_exists("#{@apptmp}/sample_project/app/mailers/demo.rb")
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -191,4 +191,4 @@ class TestMigrationGenerator < Test::Unit::TestCase
191
191
  assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/002_remove_email_from_users.rb")
192
192
  end
193
193
  end
194
- end
194
+ end
@@ -325,26 +325,57 @@ class TestModelGenerator < Test::Unit::TestCase
325
325
  context "model generator testing files" do
326
326
  # BACON
327
327
  should "generate test file for bacon" do
328
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
329
+ silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
330
+ silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
331
+ assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
332
+ assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
333
+ assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
334
+ assert_match_in_file(/'(\/\.\.){1}\/test/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
335
+ end
336
+
337
+ should "generate test file for bacon in specified app" do
328
338
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
329
339
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
330
340
  silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
331
341
  assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
332
342
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
333
343
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
344
+ assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
334
345
  end
335
346
 
336
347
  # RIOT
337
348
  should "generate test file for riot" do
349
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
350
+ silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
351
+ silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
352
+ assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
353
+ assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
354
+ assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
355
+ assert_match_in_file(/'(\/\.\.){1}\/test/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
356
+ end
357
+
358
+ should "generate test file for riot in specified app" do
338
359
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
339
360
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
340
361
  silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
341
362
  assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
342
363
  assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
343
364
  assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
365
+ assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
344
366
  end
345
367
 
346
368
  # RSPEC
347
369
  should "generate test file for rspec" do
370
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
371
+ silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
372
+ silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
373
+ assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
374
+ assert_match_in_file(/let\(:some_user\) \{ SomeUser.new \}/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
375
+ assert_match_in_file(/some_user\.should_not be_nil/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
376
+ end
377
+
378
+ should "generate test file for rspec in specified app" do
348
379
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
349
380
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
350
381
  silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
@@ -355,6 +386,17 @@ class TestModelGenerator < Test::Unit::TestCase
355
386
 
356
387
  # SHOULDA
357
388
  should "generate test file for shoulda" do
389
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
390
+ silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
391
+ silence_logger { generate(:model, 'SomePerson', "-r=#{@apptmp}/sample_project") }
392
+ assert_match_in_file(/class SomePersonTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
393
+ assert_match_in_file(/context "SomePerson Model"/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
394
+ assert_match_in_file(/@some_person = SomePerson.new/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
395
+ assert_match_in_file(/assert_not_nil @some_person/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
396
+ assert_match_in_file(/'(\/\.\.){1}\/test/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
397
+ end
398
+
399
+ should "generate test file for shoulda in specified app" do
358
400
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
359
401
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
360
402
  silence_logger { generate(:model, 'SomePerson', "-a=/subby", "-r=#{@apptmp}/sample_project") }
@@ -362,16 +404,28 @@ class TestModelGenerator < Test::Unit::TestCase
362
404
  assert_match_in_file(/context "SomePerson Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
363
405
  assert_match_in_file(/@some_person = SomePerson.new/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
364
406
  assert_match_in_file(/assert_not_nil @some_person/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
407
+ assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
365
408
  end
366
409
 
367
410
  # TESTSPEC
368
411
  should "generate test file for testspec" do
412
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
413
+ silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
414
+ silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
415
+ assert_match_in_file(/context "SomeUser Model"/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
416
+ assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
417
+ assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
418
+ assert_match_in_file(/'(\/\.\.){1}\/test/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
419
+ end
420
+
421
+ should "generate test file for testspec in specified app" do
369
422
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
370
423
  silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
371
424
  silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
372
425
  assert_match_in_file(/context "SomeUser Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
373
426
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
374
427
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
428
+ assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
375
429
  end
376
430
  end
377
431
 
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease:
5
- version: 0.10.1
6
+ segments:
7
+ - 0
8
+ - 10
9
+ - 2
10
+ version: 0.10.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Padrino Team
@@ -13,7 +18,7 @@ autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
20
 
16
- date: 2011-08-01 00:00:00 -07:00
21
+ date: 2011-08-31 00:00:00 -07:00
17
22
  default_executable:
18
23
  dependencies:
19
24
  - !ruby/object:Gem::Dependency
@@ -24,7 +29,12 @@ dependencies:
24
29
  requirements:
25
30
  - - "="
26
31
  - !ruby/object:Gem::Version
27
- version: 0.10.1
32
+ hash: 51
33
+ segments:
34
+ - 0
35
+ - 10
36
+ - 2
37
+ version: 0.10.2
28
38
  type: :runtime
29
39
  version_requirements: *id001
30
40
  - !ruby/object:Gem::Dependency
@@ -35,6 +45,10 @@ dependencies:
35
45
  requirements:
36
46
  - - ~>
37
47
  - !ruby/object:Gem::Version
48
+ hash: 15
49
+ segments:
50
+ - 1
51
+ - 0
38
52
  version: "1.0"
39
53
  type: :runtime
40
54
  version_requirements: *id002
@@ -46,6 +60,11 @@ dependencies:
46
60
  requirements:
47
61
  - - ~>
48
62
  - !ruby/object:Gem::Version
63
+ hash: 29
64
+ segments:
65
+ - 2
66
+ - 4
67
+ - 1
49
68
  version: 2.4.1
50
69
  type: :runtime
51
70
  version_requirements: *id003
@@ -171,12 +190,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
190
  requirements:
172
191
  - - ">="
173
192
  - !ruby/object:Gem::Version
193
+ hash: 3
194
+ segments:
195
+ - 0
174
196
  version: "0"
175
197
  required_rubygems_version: !ruby/object:Gem::Requirement
176
198
  none: false
177
199
  requirements:
178
200
  - - ">="
179
201
  - !ruby/object:Gem::Version
202
+ hash: 23
203
+ segments:
204
+ - 1
205
+ - 3
206
+ - 6
180
207
  version: 1.3.6
181
208
  requirements: []
182
209