merb-gen 1.0.15 → 1.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Rakefile +59 -69
  2. data/bin/merb-gen +14 -2
  3. data/lib/generators/fcgi.rb +16 -0
  4. data/lib/generators/merb/merb_core.rb +14 -12
  5. data/lib/generators/merb/merb_flat.rb +11 -6
  6. data/lib/generators/merb/merb_stack.rb +14 -22
  7. data/lib/generators/merb/merb_very_flat.rb +32 -11
  8. data/lib/generators/passenger.rb +15 -0
  9. data/lib/generators/resource_controller.rb +1 -1
  10. data/lib/generators/templates/application/common/Gemfile +12 -0
  11. data/lib/generators/templates/application/common/Rakefile +10 -1
  12. data/lib/generators/templates/application/common/dotgitignore +3 -3
  13. data/lib/generators/templates/application/common/merb +20 -0
  14. data/lib/generators/templates/application/merb_core/autotest/merb_rspec.rb +9 -9
  15. data/lib/generators/templates/application/merb_core/config/init.rb +3 -5
  16. data/lib/generators/templates/application/merb_core/spec/spec.opts +1 -1
  17. data/lib/generators/templates/application/merb_core/spec/spec_helper.rb +9 -7
  18. data/lib/generators/templates/application/merb_core/test/test_helper.rb +9 -7
  19. data/lib/generators/templates/application/merb_flat/application.rbt +3 -0
  20. data/lib/generators/templates/application/merb_flat/config/init.rb +23 -19
  21. data/lib/generators/templates/application/merb_flat/spec/spec_helper.rb +8 -6
  22. data/lib/generators/templates/application/merb_flat/test/test_helper.rb +9 -7
  23. data/lib/generators/templates/application/merb_plugin/Rakefile +35 -4
  24. data/lib/generators/templates/application/merb_stack/Gemfile +48 -0
  25. data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +7 -7
  26. data/lib/generators/templates/application/merb_stack/config/init.rb +2 -2
  27. data/lib/generators/templates/application/merb_stack/config.ru +23 -0
  28. data/lib/generators/templates/application/merb_stack/spec/spec.opts +1 -1
  29. data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +9 -7
  30. data/lib/generators/templates/application/merb_stack/test/test_helper.rb +9 -7
  31. data/lib/generators/templates/application/merb_very_flat/application.rbt +1 -8
  32. data/lib/generators/templates/application/merb_very_flat/spec/spec_helper.rb +8 -6
  33. data/lib/generators/templates/application/merb_very_flat/test/test_helper.rb +9 -7
  34. data/lib/generators/templates/{application/common → component/fcgi}/dothtaccess +1 -2
  35. data/lib/generators/templates/{application/merb_stack/public → component/fcgi}/merb.fcgi +10 -4
  36. data/lib/generators/templates/component/model/spec/models/%file_name%_spec.rb +1 -1
  37. data/lib/merb-gen/app_generator.rb +58 -0
  38. data/lib/merb-gen/generator.rb +1 -1
  39. data/lib/merb-gen/version.rb +17 -0
  40. data/lib/merb-gen.rb +27 -25
  41. data/spec/controller_spec.rb +1 -1
  42. data/spec/fcgi_spec.rb +24 -0
  43. data/spec/generator_spec.rb +1 -1
  44. data/spec/layout_spec.rb +1 -1
  45. data/spec/merb_core_spec.rb +17 -5
  46. data/spec/merb_flat_spec.rb +10 -1
  47. data/spec/merb_plugin_spec.rb +3 -3
  48. data/spec/merb_stack_spec.rb +23 -10
  49. data/spec/merb_very_flat_spec.rb +13 -2
  50. data/spec/migration_spec.rb +1 -1
  51. data/spec/model_spec.rb +1 -1
  52. data/spec/named_generator_spec.rb +1 -1
  53. data/spec/namespaced_generator_spec.rb +1 -1
  54. data/spec/part_controller_spec.rb +1 -1
  55. data/spec/passenger_spec.rb +20 -0
  56. data/spec/resource_controller_spec.rb +1 -1
  57. data/spec/resource_spec.rb +1 -1
  58. data/spec/session_migration_spec.rb +1 -1
  59. data/spec/spec.opts +2 -0
  60. data/spec/spec_helper.rb +53 -4
  61. metadata +78 -45
  62. data/lib/generators/templates/application/common/doc.thor +0 -149
  63. data/lib/generators/templates/application/common/merb_thor/app_script.rb +0 -31
  64. data/lib/generators/templates/application/common/merb_thor/common.rb +0 -68
  65. data/lib/generators/templates/application/common/merb_thor/gem_ext.rb +0 -125
  66. data/lib/generators/templates/application/common/merb_thor/main.thor +0 -151
  67. data/lib/generators/templates/application/common/merb_thor/ops.rb +0 -93
  68. data/lib/generators/templates/application/common/merb_thor/utils.rb +0 -40
  69. data/lib/generators/templates/application/merb_core/public/merb.fcgi +0 -22
  70. data/lib/generators/templates/application/merb_stack/config/dependencies.rb +0 -34
  71. data/lib/generators/thor.rb +0 -33
data/Rakefile CHANGED
@@ -1,78 +1,68 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "rake_helpers"))
2
-
3
- ##############################################################################
4
- # Package && release
5
- ##############################################################################
6
- RUBY_FORGE_PROJECT = "merb"
7
- PROJECT_URL = "http://merbivore.com"
8
- PROJECT_SUMMARY = "Generators suite for Merb."
9
- PROJECT_DESCRIPTION = PROJECT_SUMMARY
10
-
11
- GEM_AUTHOR = "Jonas Nicklas"
12
- GEM_EMAIL = "jonas.nicklas@gmail.com"
13
-
14
- GEM_NAME = "merb-gen"
15
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
16
- GEM_VERSION = Merb::VERSION + PKG_BUILD
17
-
18
- RELEASE_NAME = "REL #{GEM_VERSION}"
19
-
20
- require "extlib/tasks/release"
21
-
22
- spec = Gem::Specification.new do |s|
23
- s.rubyforge_project = RUBY_FORGE_PROJECT
24
- s.name = GEM_NAME
25
- s.version = GEM_VERSION
26
- s.platform = Gem::Platform::RUBY
27
- s.has_rdoc = true
28
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
29
- s.summary = PROJECT_SUMMARY
30
- s.description = PROJECT_DESCRIPTION
31
- s.author = GEM_AUTHOR
32
- s.email = GEM_EMAIL
33
- s.homepage = PROJECT_URL
34
- s.bindir = "bin"
35
- s.executables = %w( merb-gen )
36
-
37
- s.add_dependency "merb-core", ">= #{Merb::VERSION}"
38
- s.add_dependency "templater", ">= 0.3.3"
39
-
40
- s.require_path = 'lib'
41
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,bin,spec,merb}/**/*")
42
- end
1
+ require 'rubygems'
2
+ require 'rake'
43
3
 
44
- Rake::GemPackageTask.new(spec) do |pkg|
45
- pkg.gem_spec = spec
46
- end
4
+ # Assume a typical dev checkout to fetch the current merb-core version
5
+ require File.expand_path('../../merb-core/lib/merb-core/version', __FILE__)
47
6
 
48
- desc "Install the gem"
49
- task :install do
50
- Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
51
- end
7
+ # Load this library's version information
8
+ require File.expand_path('../lib/merb-gen/version', __FILE__)
52
9
 
53
- desc "Uninstall the gem"
54
- task :uninstall do
55
- Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
56
- end
10
+ begin
11
+
12
+ gem 'jeweler', '~> 1.4'
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gemspec|
16
+
17
+ gemspec.version = Merb::Generators::VERSION
18
+
19
+ gemspec.name = "merb-gen"
20
+ gemspec.description = "Merb plugin containing useful code generators"
21
+ gemspec.summary = "Merb plugin that provides a suite of code generators for Merb."
22
+
23
+ gemspec.authors = [ "Jonas Nicklas" ]
24
+ gemspec.email = "jonas.nicklas@gmail.com"
25
+ gemspec.homepage = "http://merbivore.com/"
26
+
27
+ gemspec.files = %w(LICENSE Rakefile README TODO) + Dir['{bin,lib,spec}/**/*']
28
+
29
+ # Runtime dependencies
30
+ gemspec.add_dependency('merb-core', "~> #{Merb::VERSION}")
31
+ gemspec.add_dependency "templater", ">= 1.0.0"
32
+
33
+ # Development dependencies
34
+ gemspec.add_development_dependency 'rspec', '>= 1.2.9'
35
+
36
+ # Executable files
37
+ gemspec.executables = 'merb-gen'
57
38
 
58
- desc "Create a gemspec file"
59
- task :gemspec do
60
- File.open("#{GEM_NAME}.gemspec", "w") do |file|
61
- file.puts spec.to_ruby
62
39
  end
40
+
41
+ Jeweler::GemcutterTasks.new
42
+
43
+ rescue LoadError
44
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
63
45
  end
64
46
 
65
- desc "Run all examples (or a specific spec with TASK=xxxx)"
66
- Spec::Rake::SpecTask.new('spec') do |t|
67
- t.spec_opts = ["-cfs"]
68
- t.spec_files = begin
69
- if ENV["TASK"]
70
- ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
71
- else
72
- FileList['spec/**/*_spec.rb']
73
- end
74
- end
47
+ require 'spec/rake/spectask'
48
+ Spec::Rake::SpecTask.new(:spec) do |spec|
49
+ spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
50
+ spec.libs << 'lib' << 'spec'
51
+ spec.spec_files = FileList['spec/**/*_spec.rb']
52
+ end
53
+
54
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
55
+ spec.libs << 'lib' << 'spec'
56
+ spec.pattern = 'spec/**/*_spec.rb'
57
+ spec.rcov = true
75
58
  end
76
59
 
77
- desc 'Default: run spec examples'
78
- task :default => 'spec'
60
+ task :default => :spec
61
+
62
+ require 'rake/rdoctask'
63
+ Rake::RDocTask.new do |rdoc|
64
+ rdoc.rdoc_dir = 'rdoc'
65
+ rdoc.title = "test_gem #{Merb::Generators::VERSION}"
66
+ rdoc.rdoc_files.include('README*')
67
+ rdoc.rdoc_files.include('lib/**/*.rb')
68
+ end
data/bin/merb-gen CHANGED
@@ -1,6 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
3
  require 'merb-gen'
5
4
 
6
- Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
5
+ begin
6
+ # Just in case the bundle was locked
7
+ # This shouldn't happen in a dev environment but lets be safe
8
+ require '.bundle/environment'
9
+ rescue LoadError
10
+ begin
11
+ require 'rubygems'
12
+ require 'bundler'
13
+ Bundler.setup
14
+ rescue Bundler::GemfileNotFound
15
+ end
16
+ end
17
+
18
+ Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
@@ -0,0 +1,16 @@
1
+ module Merb::Generators
2
+ class FcgiGenerator < AppGenerator
3
+
4
+ desc <<-DESC
5
+ Generates the configuration files needed to run Merb with FastCGI.
6
+ DESC
7
+
8
+ def self.source_root
9
+ File.join(super, 'component', 'fcgi')
10
+ end
11
+
12
+ file :dothtaccess, "dothtaccess", File.join("public", ".htaccess")
13
+ file :merbfcgi, "merb.fcgi", File.join("public", "merb.fcgi")
14
+ end
15
+ add :fcgi, FcgiGenerator
16
+ end
@@ -44,7 +44,19 @@ module Merb
44
44
  # ==== Common directories & files
45
45
  #
46
46
 
47
- empty_directory :gems, 'gems'
47
+ empty_directory :lib_tasks, 'lib/tasks'
48
+
49
+ empty_directory :bin, 'bin'
50
+ template :merb do |template|
51
+ template.source = File.join(common_templates_dir, "merb")
52
+ template.destination = "bin/merb"
53
+ end
54
+
55
+ template :gemfile do |template|
56
+ template.source = File.join(common_templates_dir, "Gemfile")
57
+ template.destination = "Gemfile"
58
+ end
59
+
48
60
  template :rakefile do |template|
49
61
  template.source = File.join(common_templates_dir, "Rakefile")
50
62
  template.destination = "Rakefile"
@@ -55,22 +67,12 @@ module Merb
55
67
  file.destination = ".gitignore"
56
68
  end
57
69
 
58
- file :htaccess do |file|
59
- file.source = File.join(common_templates_dir, 'dothtaccess')
60
- file.destination = 'public/.htaccess'
61
- end
62
-
63
70
  directory :test_dir do |directory|
64
71
  dir = testing_framework == :rspec ? "spec" : "test"
65
72
 
66
73
  directory.source = File.join(source_root, dir)
67
74
  directory.destination = dir
68
75
  end
69
-
70
- directory :thor_file do |directory|
71
- directory.source = File.join(common_templates_dir, "merb_thor")
72
- directory.destination = File.join("tasks", "merb.thor")
73
- end
74
76
 
75
77
  #
76
78
  # ==== Layout specific things
@@ -83,7 +85,7 @@ module Merb
83
85
  glob! "config"
84
86
  glob! "doc", []
85
87
  glob! "public"
86
-
88
+
87
89
  invoke :layout do |generator|
88
90
  generator.new(destination_root, options, 'application')
89
91
  end
@@ -44,7 +44,17 @@ module Merb
44
44
  # ==== Common directories & files
45
45
  #
46
46
 
47
- empty_directory :gems, 'gems'
47
+ empty_directory :bin, 'bin'
48
+ template :merb do |template|
49
+ template.source = File.join(common_templates_dir, "merb")
50
+ template.destination = "bin/merb"
51
+ end
52
+
53
+ template :gemfile do |template|
54
+ template.source = File.join(common_templates_dir, "Gemfile")
55
+ template.destination = "Gemfile"
56
+ end
57
+
48
58
  template :rakefile do |template|
49
59
  template.source = File.join(common_templates_dir, "Rakefile")
50
60
  template.destination = "Rakefile"
@@ -62,11 +72,6 @@ module Merb
62
72
  directory.destination = dir
63
73
  end
64
74
 
65
- directory :thor_file do |directory|
66
- directory.source = File.join(common_templates_dir, "merb_thor")
67
- directory.destination = File.join("tasks", "merb.thor")
68
- end
69
-
70
75
  #
71
76
  # ==== Layout specific things
72
77
  #
@@ -1,3 +1,5 @@
1
+ require 'merb-gen/version'
2
+
1
3
  module Merb
2
4
  module Generators
3
5
  class MerbStackGenerator < AppGenerator
@@ -48,7 +50,14 @@ module Merb
48
50
  # ==== Common directories & files
49
51
  #
50
52
 
51
- empty_directory :gems, 'gems'
53
+ empty_directory :bin, 'bin'
54
+ template :merb do |template|
55
+ template.source = File.join(common_templates_dir, "merb")
56
+ template.destination = "bin/merb"
57
+ end
58
+
59
+ empty_directory :lib_tasks, 'lib/tasks'
60
+
52
61
  template :rakefile do |template|
53
62
  template.source = File.join(common_templates_dir, "Rakefile")
54
63
  template.destination = "Rakefile"
@@ -59,26 +68,11 @@ module Merb
59
68
  file.destination = ".gitignore"
60
69
  end
61
70
 
62
- file :htaccess do |file|
63
- file.source = File.join(common_templates_dir, 'dothtaccess')
64
- file.destination = 'public/.htaccess'
65
- end
66
-
67
- file :doctask do |file|
68
- file.source = File.join(common_templates_dir, 'doc.thor')
69
- file.destination = 'tasks/doc.thor'
70
- end
71
-
72
71
  file :jquery do |file|
73
72
  file.source = File.join(common_templates_dir, 'jquery.js')
74
73
  file.destination = 'public/javascripts/jquery.js'
75
74
  end
76
75
 
77
- directory :thor_file do |directory|
78
- directory.source = File.join(common_templates_dir, "merb_thor")
79
- directory.destination = File.join("tasks", "merb.thor")
80
- end
81
-
82
76
  directory :test_dir do |directory|
83
77
  dir = testing_framework == :rspec ? "spec" : "test"
84
78
 
@@ -89,17 +83,15 @@ module Merb
89
83
  #
90
84
  # ==== Layout specific things
91
85
  #
92
-
93
- def merb_gems_version
94
- Merb::VERSION
95
- end
86
+ template :gemfile, "Gemfile", "Gemfile"
87
+ file :passenger_config, "config.ru"
96
88
 
97
89
  def dm_gems_version
98
- Merb::DM_VERSION
90
+ Merb::Generators::DM_VERSION_REQUIREMENT
99
91
  end
100
92
 
101
93
  def do_gems_version
102
- Merb::DO_VERSION
94
+ Merb::Generators::DO_VERSION_REQUIREMENT
103
95
  end
104
96
 
105
97
  # empty array means all files are considered to be just
@@ -1,6 +1,10 @@
1
1
  module Merb
2
2
  module Generators
3
3
  class MerbVeryFlatGenerator < AppGenerator
4
+ #
5
+ # ==== Paths
6
+ #
7
+
4
8
  def self.source_root
5
9
  File.join(super, 'application', 'merb_very_flat')
6
10
  end
@@ -15,10 +19,13 @@ module Merb
15
19
  end
16
20
 
17
21
  def common_templates_dir
18
- File.expand_path(File.join(File.dirname(__FILE__), '..',
19
- 'templates', 'application', 'common'))
22
+ self.class.common_templates_dir
20
23
  end
21
24
 
25
+ #
26
+ # ==== Generator options
27
+ #
28
+
22
29
  option :testing_framework, :default => :rspec,
23
30
  :desc => 'Testing framework to use (one of: rspec, test_unit).'
24
31
  option :orm, :default => :none,
@@ -33,6 +40,26 @@ module Merb
33
40
 
34
41
  first_argument :name, :required => true, :desc => "Application name"
35
42
 
43
+ #
44
+ # ==== Common directories & files
45
+ #
46
+
47
+ empty_directory :bin, 'bin'
48
+ template :merb do |template|
49
+ template.source = File.join(common_templates_dir, "merb")
50
+ template.destination = "bin/merb"
51
+ end
52
+
53
+ template :gemfile do |template|
54
+ template.source = File.join(common_templates_dir, "Gemfile")
55
+ template.destination = "Gemfile"
56
+ end
57
+
58
+ template :rakefile do |template|
59
+ template.source = File.join(common_templates_dir, "Rakefile")
60
+ template.destination = "Rakefile"
61
+ end
62
+
36
63
  template :application do |template|
37
64
  template.source = 'application.rbt'
38
65
  template.destination = "#{base_name}.rb"
@@ -49,15 +76,9 @@ module Merb
49
76
  directory.destination = dir
50
77
  end
51
78
 
52
- directory :thor_file do |directory|
53
- directory.source = File.join(common_templates_dir, "merb_thor")
54
- directory.destination = File.join("tasks", "merb.thor")
55
- end
56
-
57
- template :rakefile do |template|
58
- template.source = File.join(common_templates_dir, "Rakefile")
59
- template.destination = "Rakefile"
60
- end
79
+ #
80
+ # ==== Layout specific things
81
+ #
61
82
 
62
83
  def class_name
63
84
  self.name.gsub("-", "_").camel_case
@@ -0,0 +1,15 @@
1
+ module Merb::Generators
2
+ class PassengerGenerator < AppGenerator
3
+
4
+ desc <<-DESC
5
+ Generates the configuration files needed to run Merb with Phusion Passenger.
6
+ DESC
7
+
8
+ def self.source_root
9
+ File.join(super, 'application', 'merb_stack')
10
+ end
11
+
12
+ file :config, "config.ru"
13
+ end
14
+ add :passenger, PassengerGenerator
15
+ end
@@ -32,7 +32,7 @@ module Merb::Generators
32
32
  template.destination = "app/controllers" / base_path / "#{file_name}.rb"
33
33
  self.add_resource_route(self.plural_model) unless skip_route_definition?
34
34
  end
35
-
35
+
36
36
  [:index, :show, :edit, :new].each do |view|
37
37
  template "view_#{view}_none".to_sym, :template_engine => :erb, :orm => :none do |template|
38
38
  template.source = "app/views/%file_name%/#{view}.html.erb"
@@ -0,0 +1,12 @@
1
+ # dependencies are generated using a strict version, don't forget to edit the dependency versions when upgrading.
2
+ merb_gems_version = "<%= merb_gems_version %>"
3
+
4
+ # If you did disable json for Merb, comment out this line.
5
+ # If you want use json gem just change it.
6
+ # Don't use json gem version lower than 1.1.7! Older versions has security bug!
7
+ gem "json_pure", ">= 1.1.7", :require => "json"
8
+ gem "merb-core", merb_gems_version
9
+
10
+ <%= gems_for_orm(orm) %>
11
+ <%= gems_for_template_engine(template_engine) %>
12
+ <%= gems_for_testing_framework(testing_framework) %>
@@ -1,4 +1,13 @@
1
- require 'rubygems'
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require '.bundle/environment'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
10
+
2
11
  require 'rake/rdoctask'
3
12
 
4
13
  require 'merb-core'
@@ -16,6 +16,6 @@ src/*
16
16
  .hgignore
17
17
  .hg/*
18
18
  .svn/*
19
- gems/gems/*
20
- gems/specifications/*
21
- merb_profile_results
19
+ gems/
20
+ !gems/cache/
21
+ merb_profile_results
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ # Just in case the bundle was locked
5
+ # This shouldn't happen in a dev environment but lets be safe
6
+ require File.expand_path('.bundle/environment', __FILE__)
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ require 'bundler'
10
+ Bundler.setup
11
+ end
12
+
13
+ require 'merb-core'
14
+
15
+ ARGV.push '-H' if ARGV[0] && ARGV[0] =~ /^[^-]/
16
+ unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
17
+ ARGV.push *%w[-a mongrel]
18
+ end
19
+
20
+ Merb.start
@@ -14,7 +14,7 @@ class Autotest::MerbRspec < Autotest
14
14
  super
15
15
 
16
16
  # Ignore any happenings in these directories
17
- add_exception %r%^\./(?:doc|log|public|tmp|\.git|\.hg|\.svn|framework|gems|schema|\.DS_Store|autotest|bin|.*\.sqlite3)%
17
+ add_exception %r%^\./(?:doc|log|public|tmp|\.git|\.hg|\.svn|framework|gems|schema|\.DS_Store|autotest|bin|.*\.sqlite3|.*\.thor)%
18
18
  # Ignore SCM directories and custom Autotest mappings
19
19
  %w[.svn .hg .git .autotest].each { |exception| add_exception(exception) }
20
20
 
@@ -44,7 +44,7 @@ class Autotest::MerbRspec < Autotest
44
44
  # Any change to global_helpers will result in all view and controller
45
45
  # tests being run
46
46
  add_mapping %r%^app/helpers/global_helpers\.rb% do
47
- files_matching %r%^spec/(views|controllers|helpers)/.*_spec\.rb$%
47
+ files_matching %r%^spec/(views|controllers|helpers|requests)/.*_spec\.rb$%
48
48
  end
49
49
 
50
50
  # Any change to a helper will cause its spec to be run
@@ -54,7 +54,7 @@ class Autotest::MerbRspec < Autotest
54
54
 
55
55
  # Changes to a view cause its spec to be run
56
56
  add_mapping %r%^app/views/(.*)/% do |_, m|
57
- spec_for(m[1], 'view')
57
+ spec_for(m[1], 'request')
58
58
  end
59
59
 
60
60
  # Changes to a controller result in its corresponding spec being run. If
@@ -62,15 +62,15 @@ class Autotest::MerbRspec < Autotest
62
62
  # controller specs are run.
63
63
  add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
64
64
  if ["application", "exception"].include?(m[1])
65
- files_matching %r%^spec/controllers/.*_spec\.rb$%
65
+ files_matching %r%^spec/requests/.*_spec\.rb$%
66
66
  else
67
- spec_for(m[1], 'controller')
67
+ spec_for(m[1], 'request')
68
68
  end
69
69
  end
70
70
 
71
71
  # If a change is made to the router, run controller, view and helper specs
72
72
  add_mapping %r%^config/router.rb$% do
73
- files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
73
+ files_matching %r%^spec/(views|controllers|helpers|requests)/.*_spec\.rb$%
74
74
  end
75
75
 
76
76
  # If any of the major files governing the environment are altered, run
@@ -157,9 +157,9 @@ private
157
157
  # String
158
158
  #
159
159
  # ==== Example
160
- # > spec_for('post', :view')
161
- # => "spec/views/post_spec.rb"
160
+ # > spec_for('post', :model')
161
+ # => "spec/models/post_spec.rb"
162
162
  def spec_for(match, kind)
163
- File.join("spec", kind + 's', "#{match}_spec.rb")
163
+ files_matching %r%^spec/#{kind}s/#{match}(/.*)?_spec.rb$%
164
164
  end
165
165
  end
@@ -1,9 +1,7 @@
1
1
  # Go to http://wiki.merbivore.com/pages/init-rb
2
-
3
- # Specify a specific version of a dependency
4
- # dependency "RedCloth", "> 3.0"
5
2
 
6
- <%= "# " unless orm != :none %> use_orm :<%= orm %>
3
+ # Specify your dependencies in the Gemfile
4
+ <%= "use_orm :#{orm}" unless orm == :none %>
7
5
  use_test :<%= testing_framework %>
8
6
  use_template_engine :<%= template_engine %>
9
7
 
@@ -22,4 +20,4 @@ end
22
20
 
23
21
  Merb::BootLoader.after_app_loads do
24
22
  # This will get executed after your app's classes have been loaded.
25
- end
23
+ end
@@ -1,2 +1,2 @@
1
1
  --format specdoc
2
- --colour
2
+ --colour
@@ -1,13 +1,15 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
- require "merb-core"
10
11
  require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
12
+ require "merb-core"
11
13
 
12
14
  # this loads all plugins required in your init file so don't add them
13
15
  # here again, Merb will do it for you
@@ -1,9 +1,11 @@
1
- require "rubygems"
2
-
3
- # Add the local gems dir if found within the app root; any dependencies loaded
4
- # hereafter will try to load from the local gems before loading system gems.
5
- if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
- $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
7
9
  end
8
10
 
9
11
  require "merb-core"
@@ -16,4 +18,4 @@ Merb.start :environment => (ENV['MERB_ENV'] || 'test'),
16
18
  class Test::Unit::TestCase
17
19
  include Merb::Test::RequestHelper
18
20
  # Add more helper methods to be used by all tests here...
19
- end
21
+ end
@@ -1,5 +1,8 @@
1
1
  class <%= class_name %> < Merb::Controller
2
2
 
3
+ # Templates go in: views/index.html.<%= template_engine %>
4
+ # Layouts go in: views/layout.application.html.<%= template_engine %>
5
+ # Modify this method to use another location.
3
6
  def _template_location(action, type = nil, controller = controller_name)
4
7
  controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}"
5
8
  end