padrino-gen 0.9.19 → 0.9.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +1 -1
  3. data/lib/padrino-gen/generators/components/mocks/mocha.rb +0 -2
  4. data/lib/padrino-gen/generators/components/mocks/rr.rb +0 -2
  5. data/lib/padrino-gen/generators/components/orms/activerecord.rb +5 -5
  6. data/lib/padrino-gen/generators/components/orms/datamapper.rb +4 -4
  7. data/lib/padrino-gen/generators/components/orms/mongomatic.rb +3 -3
  8. data/lib/padrino-gen/generators/components/orms/ohm.rb +2 -2
  9. data/lib/padrino-gen/generators/components/orms/sequel.rb +1 -1
  10. data/lib/padrino-gen/generators/components/renderers/erubis.rb +1 -1
  11. data/lib/padrino-gen/generators/components/renderers/slim.rb +3 -0
  12. data/lib/padrino-gen/generators/components/tests/cucumber.rb +1 -1
  13. data/lib/padrino-gen/generators/components/tests/riot.rb +1 -1
  14. data/lib/padrino-gen/generators/components/tests/rspec.rb +3 -3
  15. data/lib/padrino-gen/generators/project.rb +3 -3
  16. data/lib/padrino-gen/generators/runner.rb +1 -1
  17. data/lib/padrino-gen/padrino-tasks/activerecord.rb +2 -2
  18. data/lib/padrino-gen/padrino-tasks/seed.rb +1 -1
  19. data/test/fixtures/example_template.rb +1 -1
  20. data/test/helper.rb +1 -1
  21. data/test/test_app_generator.rb +1 -1
  22. data/test/test_cli.rb +1 -1
  23. data/test/test_controller_generator.rb +1 -1
  24. data/test/test_mailer_generator.rb +1 -1
  25. data/test/test_migration_generator.rb +6 -6
  26. data/test/test_model_generator.rb +25 -4
  27. data/test/test_plugin_generator.rb +1 -1
  28. data/test/test_project_generator.rb +12 -34
  29. metadata +8 -8
  30. data/lib/padrino-gen/generators/components/tests/rspec1.rb +0 -67
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) 2010 Padrino. See LICENSE for details.
163
+ Copyright (c) 2010 Padrino. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
1
  # coding:utf-8
2
2
  RAKE_ROOT = __FILE__
3
3
  require 'rubygems'
4
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
4
+ require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
@@ -3,8 +3,6 @@ def setup_mock
3
3
  case options[:test].to_s
4
4
  when 'rspec'
5
5
  inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "RSpec.configure do |conf|\n"
6
- when 'rspec1'
7
- inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "Spec::Runner.configure do |conf|\n"
8
6
  else
9
7
  insert_mocking_include "Mocha::API"
10
8
  end
@@ -3,8 +3,6 @@ def setup_mock
3
3
  case options[:test].to_s
4
4
  when 'rspec'
5
5
  inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "RSpec.configure do |conf|\n"
6
- when 'rspec1'
7
- inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "Spec::Runner.configure do |conf|\n"
8
6
  when 'riot'
9
7
  inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\")\n"
10
8
  else
@@ -5,7 +5,7 @@ AR = (<<-AR) unless defined?(AR)
5
5
  # ActiveRecord::Base.configurations[:development] = {
6
6
  # :adapter => 'mysql',
7
7
  # :encoding => 'utf8',
8
- # :reconnect => false,
8
+ # :reconnect => true,
9
9
  # :database => 'your_database',
10
10
  # :pool => 5,
11
11
  # :username => 'root',
@@ -49,7 +49,7 @@ AR
49
49
  MYSQL = (<<-MYSQL)
50
50
  :adapter => 'mysql',
51
51
  :encoding => 'utf8',
52
- :reconnect => false,
52
+ :reconnect => true,
53
53
  :database => !DB_NAME!,
54
54
  :pool => 5,
55
55
  :username => 'root',
@@ -61,7 +61,7 @@ MYSQL
61
61
  MYSQL2 = (<<-MYSQL2)
62
62
  :adapter => 'mysql2',
63
63
  :encoding => 'utf8',
64
- :reconnect => false,
64
+ :reconnect => true,
65
65
  :database => !DB_NAME!,
66
66
  :pool => 5,
67
67
  :username => 'root',
@@ -124,7 +124,7 @@ MODEL
124
124
  # options => { :fields => ["title:string", "body:string"], :app => 'app' }
125
125
  def create_model_file(name, options={})
126
126
  model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
127
- model_contents = AR_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
127
+ model_contents = AR_MODEL.gsub(/!NAME!/, name.to_s.camelize)
128
128
  create_file(model_path, model_contents,:skip => true)
129
129
  end
130
130
 
@@ -169,4 +169,4 @@ def create_migration_file(migration_name, name, columns)
169
169
  :add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
170
170
  :remove => Proc.new { |field, kind| "t.remove :#{field}" }
171
171
  )
172
- end
172
+ end
@@ -60,7 +60,7 @@ MODEL
60
60
  # options => { :fields => ["title:string", "body:string"], :app => 'app' }
61
61
  def create_model_file(name, options={})
62
62
  model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
63
- model_contents = DM_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
63
+ model_contents = DM_MODEL.gsub(/!NAME!/, name.to_s.camelize)
64
64
  field_tuples = options[:fields].collect { |value| value.split(":") }
65
65
  field_tuples.collect! { |field, kind| kind =~ /datetime/i ? [field, 'DateTime'] : [field, kind] } # fix datetime
66
66
  column_declarations = field_tuples.collect { |field, kind|"property :#{field}, #{kind.camelize}" }.join("\n ")
@@ -82,7 +82,7 @@ MIGRATION
82
82
 
83
83
  DM_MODEL_UP_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(DM_MODEL_UP_MG)
84
84
  create_table :!TABLE! do
85
- column :id, DataMapper::Property::Integer, :serial => true
85
+ column :id, Integer, :serial => true
86
86
  !FIELDS!
87
87
  end
88
88
  MIGRATION
@@ -93,7 +93,7 @@ MIGRATION
93
93
 
94
94
  def create_model_migration(migration_name, name, columns)
95
95
  output_model_migration(migration_name, name, columns,
96
- :column_format => Proc.new { |field, kind| "column :#{field}, DataMapper::Property::#{kind.classify}" },
96
+ :column_format => Proc.new { |field, kind| "column :#{field}, #{kind.classify}" },
97
97
  :base => DM_MIGRATION, :up => DM_MODEL_UP_MG, :down => DM_MODEL_DOWN_MG)
98
98
  end
99
99
 
@@ -106,7 +106,7 @@ MIGRATION
106
106
  def create_migration_file(migration_name, name, columns)
107
107
  output_migration_file(migration_name, name, columns,
108
108
  :base => DM_MIGRATION, :change_format => DM_CHANGE_MG,
109
- :add => Proc.new { |field, kind| "add_column :#{field}, DataMapper::Property::#{kind.classify}" },
109
+ :add => Proc.new { |field, kind| "add_column :#{field}, #{kind.classify}" },
110
110
  :remove => Proc.new { |field, kind| "drop_column :#{field}" }
111
111
  )
112
112
  end
@@ -24,7 +24,7 @@ class !NAME! < Mongomatic::Base
24
24
  # Staying true to the "ad-hoc" nature of MongoDB,
25
25
  # there are no explicit column definitions in the
26
26
  # model file.
27
-
27
+
28
28
  # However you can "fake it" by making a column
29
29
  # required using expectations
30
30
  # For the sake of padrino g model,
@@ -34,7 +34,7 @@ class !NAME! < Mongomatic::Base
34
34
  # the expectation: be_a_number
35
35
  # Future enhancement may allow a regex for
36
36
  # String datatypes
37
-
37
+
38
38
 
39
39
  # Examples
40
40
  # def validate
@@ -82,4 +82,4 @@ end
82
82
 
83
83
  def create_migration_file(migration_name, name, columns)
84
84
  # NO MIGRATION NEEDED
85
- end
85
+ end
@@ -38,7 +38,7 @@ class !NAME! < Ohm::Model
38
38
 
39
39
  # Examples:
40
40
  # attribute :name
41
- # attribute :email, String
41
+ # attribute :email, String
42
42
  # reference :venue, Venue
43
43
  # set :participants, Person
44
44
  # counter :votes
@@ -69,4 +69,4 @@ end
69
69
 
70
70
  def create_migration_file(migration_name, name, columns)
71
71
  # NO MIGRATION NEEDED
72
- end
72
+ end
@@ -43,7 +43,7 @@ MODEL
43
43
  # options => { :fields => ["title:string", "body:string"], :app => 'app' }
44
44
  def create_model_file(name, options={})
45
45
  model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
46
- model_contents = SQ_MODEL.gsub(/!NAME!/, name.to_s.downcase.camelize)
46
+ model_contents = SQ_MODEL.gsub(/!NAME!/, name.to_s.camelize)
47
47
  create_file(model_path, model_contents)
48
48
  end
49
49
 
@@ -1,3 +1,3 @@
1
1
  def setup_renderer
2
- require_dependencies 'erubis'
2
+ require_dependencies 'erubis'
3
3
  end
@@ -0,0 +1,3 @@
1
+ def setup_renderer
2
+ require_dependencies 'slim'
3
+ end
@@ -82,4 +82,4 @@ def setup_test
82
82
  require_dependencies 'rspec', :group => 'test'
83
83
  insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
84
84
  create_file destination_root("spec/spec.rake"), RSPEC_RAKE
85
- end
85
+ end
@@ -12,7 +12,7 @@ class Riot::Situation
12
12
  ##
13
13
  # You can handle all padrino applications using instead:
14
14
  # Padrino.application
15
-
15
+
16
16
  def app
17
17
  CLASS_NAME.tap { |app| }
18
18
  end
@@ -15,7 +15,7 @@ end
15
15
  TEST
16
16
 
17
17
  RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
18
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
18
+ require 'spec_helper'
19
19
 
20
20
  describe "!NAME!Controller" do
21
21
  before do
@@ -38,7 +38,7 @@ end
38
38
  TEST
39
39
 
40
40
  RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
41
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
41
+ require 'spec_helper'
42
42
 
43
43
  describe "!NAME! Model" do
44
44
  let(:!DNAME!) { !NAME!.new }
@@ -64,4 +64,4 @@ end
64
64
  def generate_model_test(name)
65
65
  rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
66
66
  create_file destination_root("spec/models/#{name.to_s.underscore}_spec.rb"), rspec_contents, :skip => true
67
- end
67
+ end
@@ -31,10 +31,10 @@ module Padrino
31
31
 
32
32
  # Definitions for the available customizable components
33
33
  component_option :orm, "database engine", :aliases => '-d', :choices => [:activerecord, :datamapper, :mongomapper, :mongoid, :sequel, :couchrest, :ohm, :mongomatic], :default => :none
34
- component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec1, :rspec, :shoulda, :cucumber, :bacon, :testspec, :riot], :default => :none
34
+ component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec, :shoulda, :cucumber, :bacon, :testspec, :riot], :default => :none
35
35
  component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr], :default => :none
36
36
  component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools, :extcore, :dojo], :default => :none
37
- component_option :renderer, "template engine", :aliases => '-e', :choices => [:haml, :erb, :erubis, :liquid], :default => :haml
37
+ component_option :renderer, "template engine", :aliases => '-e', :choices => [:haml, :erb, :erubis, :liquid, :slim], :default => :haml
38
38
  component_option :stylesheet, "stylesheet engine", :aliases => '-c', :choices => [:less, :sass, :compass, :scss], :default => :none
39
39
 
40
40
  # Show help if no argv given
@@ -100,4 +100,4 @@ module Padrino
100
100
  end
101
101
  end # Project
102
102
  end # Generators
103
- end # Padrino
103
+ end # Padrino
@@ -87,4 +87,4 @@ module Padrino
87
87
  end
88
88
  end # Runner
89
89
  end # Generators
90
- end # Padrino
90
+ end # Padrino
@@ -342,7 +342,7 @@ if defined?(ActiveRecord)
342
342
  locale = "#{lang}:" + "\n" +
343
343
  " models:" + "\n" +
344
344
  " #{m}:" + "\n" +
345
- " name: #{klass.human_name}" + "\n" +
345
+ " name: #{klass.human}" + "\n" +
346
346
  " attributes:" + "\n" +
347
347
  columns.collect { |c| " #{c}: #{klass.human_attribute_name(c)}" }.join("\n")
348
348
  print "created a new for #{lang.to_s.upcase} Lang ... "; $stdout.flush
@@ -567,4 +567,4 @@ if defined?(ActiveRecord)
567
567
  end
568
568
 
569
569
  ActiveRecord::Migration.send :include, AutoMigrations
570
- end
570
+ 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
@@ -11,4 +11,4 @@ initializer :test, "# Example"
11
11
 
12
12
  app :testapp do
13
13
  generate :controller, "users get:index"
14
- end
14
+ end
data/test/helper.rb CHANGED
@@ -153,4 +153,4 @@ module Webrat
153
153
  @logger = nil
154
154
  end
155
155
  end
156
- end
156
+ end
@@ -79,4 +79,4 @@ class TestAppGenerator < Test::Unit::TestCase
79
79
  assert_no_match_in_file(/Padrino\.mount\("Demo"\).to\("\/demo"\)/,"#{@apptmp}/sample_project/config/apps.rb")
80
80
  end
81
81
  end
82
- end
82
+ 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
@@ -130,4 +130,4 @@ class TestControllerGenerator < Test::Unit::TestCase
130
130
  assert_no_file_exists("#{@apptmp}/sample_project/spec/controllers/demo_items_controller_spec.rb")
131
131
  end
132
132
  end
133
- end
133
+ 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
@@ -14,7 +14,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
14
14
  should "fail outside app root" do
15
15
  output = silence_logger { generate(:migration, 'add_email_to_users', '-r=/tmp') }
16
16
  assert_match(/not at the root/, output)
17
- assert_no_file_exists("#{@apptmp}/db/migration")
17
+ assert_no_file_exists("#{@apptmp}/db/migrate")
18
18
  end
19
19
 
20
20
  should "fail if we don't use an adapter" do
@@ -107,8 +107,8 @@ class TestMigrationGenerator < Test::Unit::TestCase
107
107
  response_success = silence_logger { generate(:migration, *migration_params) }
108
108
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_add_email_to_users.rb"
109
109
  assert_match_in_file(/migration\s1.*?:add_email_to_users/m, migration_file_path)
110
- assert_match_in_file(/modify_table :users.*?add_column :email, DataMapper::Property::String/m, migration_file_path)
111
- assert_match_in_file(/add_column :age, DataMapper::Property::Integer/m, migration_file_path)
110
+ assert_match_in_file(/modify_table :users.*?add_column :email, String/m, migration_file_path)
111
+ assert_match_in_file(/add_column :age, Integer/m, migration_file_path)
112
112
  assert_match_in_file(/modify_table :users.*?drop_column :email/m, migration_file_path)
113
113
  assert_match_in_file(/drop_column :age/m, migration_file_path)
114
114
  end
@@ -121,8 +121,8 @@ class TestMigrationGenerator < Test::Unit::TestCase
121
121
  assert_match_in_file(/migration\s1.*?:remove_email_from_users/m, migration_file_path)
122
122
  assert_match_in_file(/modify_table :users.*?drop_column :email/m, migration_file_path)
123
123
  assert_match_in_file(/drop_column :age/m, migration_file_path)
124
- assert_match_in_file(/modify_table :users.*?add_column :email, DataMapper::Property::String/m, migration_file_path)
125
- assert_match_in_file(/add_column :age, DataMapper::Property::Integer/m, migration_file_path)
124
+ assert_match_in_file(/modify_table :users.*?add_column :email, String/m, migration_file_path)
125
+ assert_match_in_file(/add_column :age, Integer/m, migration_file_path)
126
126
  end
127
127
 
128
128
  should "properly version migration files" do
@@ -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
@@ -86,6 +86,13 @@ class TestModelGenerator < Test::Unit::TestCase
86
86
  assert_match_in_file(/class User < ActiveRecord::Base/m, "#{@apptmp}/sample_project/app/models/user.rb")
87
87
  end
88
88
 
89
+ should "generate model file with camelized name" do
90
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
91
+ silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
92
+ assert_match_in_file(/class ChunkyBacon < ActiveRecord::Base/m, "#{@apptmp}/sample_project/app/models/chunky_bacon.rb")
93
+ assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
94
+ end
95
+
89
96
  should "generate migration file with no fields" do
90
97
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
91
98
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
@@ -140,6 +147,13 @@ class TestModelGenerator < Test::Unit::TestCase
140
147
  assert_match_in_file(/gem 'data_mapper'/m,"#{@apptmp}/sample_project/Gemfile")
141
148
  end
142
149
 
150
+ should "generate model file with camelized name" do
151
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=datamapper') }
152
+ silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
153
+ assert_match_in_file(/class ChunkyBacon\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/app/models/chunky_bacon.rb")
154
+ assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
155
+ end
156
+
143
157
  should "generate model file with fields" do
144
158
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
145
159
  silence_logger { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
@@ -170,9 +184,9 @@ class TestModelGenerator < Test::Unit::TestCase
170
184
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
171
185
  assert_match_in_file(/migration 1, :create_people do/m, migration_file_path)
172
186
  assert_match_in_file(/create_table :people do/m, migration_file_path)
173
- assert_match_in_file(/column :name, DataMapper::Property::String/m, migration_file_path)
174
- assert_match_in_file(/column :created_at, DataMapper::Property::DateTime/m, migration_file_path)
175
- assert_match_in_file(/column :email, DataMapper::Property::String/m, migration_file_path)
187
+ assert_match_in_file(/column :name, String/m, migration_file_path)
188
+ assert_match_in_file(/column :created_at, DateTime/m, migration_file_path)
189
+ assert_match_in_file(/column :email, String/m, migration_file_path)
176
190
  assert_match_in_file(/drop_table :people/m, migration_file_path)
177
191
  end
178
192
  end
@@ -185,6 +199,13 @@ class TestModelGenerator < Test::Unit::TestCase
185
199
  assert_match_in_file(/class User < Sequel::Model/m, "#{@apptmp}/sample_project/app/models/user.rb")
186
200
  end
187
201
 
202
+ should "generate model file with camelized name" do
203
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=sequel') }
204
+ silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
205
+ assert_match_in_file(/class ChunkyBacon < Sequel::Model/m, "#{@apptmp}/sample_project/app/models/chunky_bacon.rb")
206
+ assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
207
+ end
208
+
188
209
  should "generate migration file with given properties" do
189
210
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
190
211
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
@@ -357,4 +378,4 @@ class TestModelGenerator < Test::Unit::TestCase
357
378
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_bar_foos.rb")
358
379
  end
359
380
  end
360
- end
381
+ end
@@ -125,4 +125,4 @@ class TestPluginGenerator < Test::Unit::TestCase
125
125
  expects_generated :admin_page, "post -r=#{@apptmp}/sample_admin"
126
126
  end
127
127
  end
128
- end
128
+ end
@@ -29,13 +29,13 @@ class TestProjectGenerator < Test::Unit::TestCase
29
29
  assert_match_in_file(/class ProjectCom < Padrino::Application/,"#{@apptmp}/project.com/app/app.rb")
30
30
  assert_match_in_file(/Padrino.mount\("ProjectCom"\).to\('\/'\)/,"#{@apptmp}/project.com/config/apps.rb")
31
31
  end
32
-
32
+
33
33
  should "display the right path" do
34
34
  buffer = silence_logger { generate(:project, 'project', "--root=/tmp") }
35
35
  assert_file_exists("/tmp/project")
36
36
  assert_match(/cd \/tmp\/project/, buffer)
37
37
  end
38
-
38
+
39
39
 
40
40
  should "allow specifying alternate application name" do
41
41
  assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') } }
@@ -139,27 +139,12 @@ class TestProjectGenerator < Test::Unit::TestCase
139
139
  assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
140
140
  end
141
141
 
142
- should "properly generate for mocha and rspec1" do
143
- buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}",'--test=rspec1', '--mock=mocha', '--script=none') }
144
- assert_match(/Applying.*?mocha.*?mock/, buffer)
145
- assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
146
- assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
147
- end
148
-
149
142
  should "properly generate for rr and rspec" do
150
143
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=rr', '--script=none') }
151
144
  assert_match(/Applying.*?rr.*?mock/, buffer)
152
145
  assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
153
146
  assert_match_in_file(/conf.mock_with :rr/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
154
147
  end
155
-
156
- should "properly generate for rr and rspec1" do
157
- buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec1', '--mock=rr', '--script=none') }
158
- assert_match(/Applying.*?rr.*?mock/, buffer)
159
- assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
160
- assert_match_in_file(/conf.mock_with :rr/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
161
- end
162
-
163
148
  end
164
149
 
165
150
  context "the generator for orm components" do
@@ -333,19 +318,24 @@ class TestProjectGenerator < Test::Unit::TestCase
333
318
  assert_match(/Applying.*?haml.*?renderer/, buffer)
334
319
  assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
335
320
  end
336
-
337
- should "properly generate for erubis" do
321
+
322
+ should "properly generate for erubis" do
338
323
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=erubis','--script=none') }
339
324
  assert_match(/Applying.*?erubis.*?renderer/,buffer)
340
325
  assert_match_in_file(/gem 'erubis'/, "#{@apptmp}/sample_project/Gemfile")
341
326
  end
342
327
 
343
- should "properly generate for liquid" do
328
+ should "properly generate for liquid" do
344
329
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=liquid','--script=none') }
345
330
  assert_match(/Applying.*?liquid.*?renderer/,buffer)
346
331
  assert_match_in_file(/gem 'liquid'/, "#{@apptmp}/sample_project/Gemfile")
347
332
  end
348
333
 
334
+ should "properly generate for slim" do
335
+ buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=slim','--script=none') }
336
+ assert_match(/Applying.*?slim.*?renderer/,buffer)
337
+ assert_match_in_file(/gem 'slim'/, "#{@apptmp}/sample_project/Gemfile")
338
+ end
349
339
  end
350
340
 
351
341
  context "the generator for script component" do
@@ -421,18 +411,6 @@ class TestProjectGenerator < Test::Unit::TestCase
421
411
  assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
422
412
  end
423
413
 
424
- should "properly generate for rspec1" do
425
- buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec1', '--script=none') }
426
- assert_match(/Applying.*?rspec.*?test/, buffer)
427
- assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
428
- assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
429
- assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
430
- assert_match_in_file(/gem 'rspec'.*?"~>\s*1.2.3".*?:require => "spec"/, "#{@apptmp}/sample_project/Gemfile")
431
- assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
432
- assert_match_in_file(/Spec::Runner/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
433
- assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
434
- end
435
-
436
414
  should "properly generate for rspec" do
437
415
  buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
438
416
  assert_match(/Applying.*?rspec.*?test/, buffer)
@@ -527,6 +505,6 @@ class TestProjectGenerator < Test::Unit::TestCase
527
505
  assert_match_in_file(/register ScssInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
528
506
  assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
529
507
  end
530
-
508
+
531
509
  end
532
- end
510
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 19
10
- version: 0.9.19
9
+ - 20
10
+ version: 0.9.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Padrino Team
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-11-17 00:00:00 +01:00
21
+ date: 2011-01-19 00:00:00 -08:00
22
22
  default_executable: padrino-gen
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -29,12 +29,12 @@ dependencies:
29
29
  requirements:
30
30
  - - "="
31
31
  - !ruby/object:Gem::Version
32
- hash: 29
32
+ hash: 19
33
33
  segments:
34
34
  - 0
35
35
  - 9
36
- - 19
37
- version: 0.9.19
36
+ - 20
37
+ version: 0.9.20
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
40
  - !ruby/object:Gem::Dependency
@@ -103,6 +103,7 @@ files:
103
103
  - lib/padrino-gen/generators/components/renderers/erubis.rb
104
104
  - lib/padrino-gen/generators/components/renderers/haml.rb
105
105
  - lib/padrino-gen/generators/components/renderers/liquid.rb
106
+ - lib/padrino-gen/generators/components/renderers/slim.rb
106
107
  - lib/padrino-gen/generators/components/scripts/dojo.rb
107
108
  - lib/padrino-gen/generators/components/scripts/extcore.rb
108
109
  - lib/padrino-gen/generators/components/scripts/jquery.rb
@@ -119,7 +120,6 @@ files:
119
120
  - lib/padrino-gen/generators/components/tests/cucumber.rb
120
121
  - lib/padrino-gen/generators/components/tests/riot.rb
121
122
  - lib/padrino-gen/generators/components/tests/rspec.rb
122
- - lib/padrino-gen/generators/components/tests/rspec1.rb
123
123
  - lib/padrino-gen/generators/components/tests/shoulda.rb
124
124
  - lib/padrino-gen/generators/components/tests/testspec.rb
125
125
  - lib/padrino-gen/generators/controller.rb
@@ -1,67 +0,0 @@
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/**/*_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
- let(:!DNAME!) { !NAME!.new }
45
- it 'can be created' do
46
- !DNAME!.should_not be_nil
47
- end
48
- end
49
- TEST
50
-
51
- def setup_test
52
- require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
53
- require_dependencies 'rspec', :version => "~> 1.2.3", :require => 'spec', :group => 'test'
54
- insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
55
- create_file destination_root("spec/spec.rake"), RSPEC_RAKE
56
- end
57
-
58
- # Generates a controller test given the controllers name
59
- def generate_controller_test(name)
60
- rspec_contents = RSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
61
- create_file destination_root("spec/controllers/#{name.to_s.underscore}_controller_spec.rb"), rspec_contents, :skip => true
62
- end
63
-
64
- def generate_model_test(name)
65
- rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
66
- create_file destination_root("spec/models/#{name.to_s.underscore}_spec.rb"), rspec_contents, :skip => true
67
- end