merb 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README +21 -14
  2. data/Rakefile +157 -108
  3. data/SVN_REVISION +1 -0
  4. data/app_generators/merb/templates/Rakefile +20 -4
  5. data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +1 -1
  6. data/app_generators/merb/templates/config/boot.rb +1 -1
  7. data/app_generators/merb/templates/config/dependencies.rb +3 -3
  8. data/app_generators/merb/templates/config/merb.yml +5 -0
  9. data/app_generators/merb/templates/config/merb_init.rb +3 -3
  10. data/app_generators/merb/templates/script/destroy +3 -0
  11. data/app_generators/merb/templates/script/generate +1 -1
  12. data/app_generators/merb/templates/spec/spec_helper.rb +2 -2
  13. data/app_generators/merb/templates/test/test_helper.rb +1 -1
  14. data/app_generators/merb_plugin/merb_plugin_generator.rb +4 -0
  15. data/bin/merb +1 -3
  16. data/lib/merb.rb +144 -76
  17. data/lib/merb/abstract_controller.rb +6 -5
  18. data/lib/merb/assets.rb +119 -0
  19. data/lib/merb/boot_loader.rb +217 -0
  20. data/lib/merb/caching.rb +1 -1
  21. data/lib/merb/caching/action_cache.rb +1 -1
  22. data/lib/merb/caching/fragment_cache.rb +1 -1
  23. data/lib/merb/caching/store/file_cache.rb +1 -1
  24. data/lib/merb/config.rb +290 -0
  25. data/lib/merb/controller.rb +5 -5
  26. data/lib/merb/core_ext/get_args.rb +1 -0
  27. data/lib/merb/core_ext/hash.rb +182 -169
  28. data/lib/merb/core_ext/kernel.rb +57 -26
  29. data/lib/merb/dispatcher.rb +6 -6
  30. data/lib/merb/drb_server.rb +1 -1
  31. data/lib/merb/generators/merb_generator_helpers.rb +7 -6
  32. data/lib/merb/logger.rb +1 -1
  33. data/lib/merb/mail_controller.rb +3 -4
  34. data/lib/merb/mailer.rb +2 -2
  35. data/lib/merb/mixins/basic_authentication.rb +2 -2
  36. data/lib/merb/mixins/controller.rb +1 -1
  37. data/lib/merb/mixins/general_controller.rb +13 -20
  38. data/lib/merb/mixins/inline_partial.rb +32 -0
  39. data/lib/merb/mixins/render.rb +3 -3
  40. data/lib/merb/mixins/responder.rb +1 -1
  41. data/lib/merb/mixins/view_context.rb +159 -33
  42. data/lib/merb/mongrel_handler.rb +9 -9
  43. data/lib/merb/plugins.rb +1 -1
  44. data/lib/merb/request.rb +25 -1
  45. data/lib/merb/router.rb +264 -226
  46. data/lib/merb/server.rb +66 -560
  47. data/lib/merb/session/cookie_store.rb +14 -13
  48. data/lib/merb/session/mem_cache_session.rb +20 -10
  49. data/lib/merb/session/memory_session.rb +21 -11
  50. data/lib/merb/template.rb +2 -2
  51. data/lib/merb/template/erubis.rb +3 -33
  52. data/lib/merb/template/haml.rb +8 -3
  53. data/lib/merb/test/fake_request.rb +8 -3
  54. data/lib/merb/test/helper.rb +66 -22
  55. data/lib/merb/test/rspec.rb +9 -155
  56. data/lib/merb/test/rspec_matchers/controller_matchers.rb +117 -0
  57. data/lib/merb/test/rspec_matchers/markup_matchers.rb +98 -0
  58. data/lib/merb/upload_handler.rb +2 -1
  59. data/lib/merb/version.rb +38 -3
  60. data/lib/merb/view_context.rb +1 -2
  61. data/lib/tasks/merb.rake +11 -11
  62. data/merb_generators/part_controller/USAGE +5 -0
  63. data/merb_generators/part_controller/part_controller_generator.rb +27 -0
  64. data/merb_generators/part_controller/templates/controller.rb +8 -0
  65. data/merb_generators/part_controller/templates/helper.rb +5 -0
  66. data/merb_generators/part_controller/templates/index.html.erb +3 -0
  67. data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +1 -1
  68. data/script/destroy +14 -0
  69. data/script/generate +14 -0
  70. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +9 -1
  71. data/spec/fixtures/controllers/render_spec_controllers.rb +5 -5
  72. data/spec/fixtures/models/router_spec_models.rb +10 -0
  73. data/spec/merb/abstract_controller_spec.rb +2 -2
  74. data/spec/merb/assets_spec.rb +207 -0
  75. data/spec/merb/caching_spec.rb +2 -2
  76. data/spec/merb/controller_spec.rb +7 -2
  77. data/spec/merb/cookie_store_spec.rb +1 -1
  78. data/spec/merb/core_ext/class_spec.rb +97 -0
  79. data/spec/merb/core_ext/enumerable_spec.rb +27 -0
  80. data/spec/merb/core_ext/hash_spec.rb +251 -0
  81. data/spec/merb/core_ext/inflector_spec.rb +34 -0
  82. data/spec/merb/core_ext/kernel_spec.rb +25 -0
  83. data/spec/merb/core_ext/numeric_spec.rb +26 -0
  84. data/spec/merb/core_ext/object_spec.rb +47 -0
  85. data/spec/merb/core_ext/string_spec.rb +22 -0
  86. data/spec/merb/core_ext/symbol_spec.rb +7 -0
  87. data/spec/merb/dependency_spec.rb +22 -0
  88. data/spec/merb/dispatch_spec.rb +23 -12
  89. data/spec/merb/fake_request_spec.rb +8 -0
  90. data/spec/merb/generator_spec.rb +140 -21
  91. data/spec/merb/handler_spec.rb +5 -5
  92. data/spec/merb/mail_controller_spec.rb +3 -3
  93. data/spec/merb/render_spec.rb +1 -1
  94. data/spec/merb/responder_spec.rb +3 -3
  95. data/spec/merb/router_spec.rb +260 -191
  96. data/spec/merb/server_spec.rb +5 -5
  97. data/spec/merb/upload_handler_spec.rb +7 -0
  98. data/spec/merb/version_spec.rb +33 -0
  99. data/spec/merb/view_context_spec.rb +217 -59
  100. data/spec/spec_generator_helper.rb +15 -0
  101. data/spec/spec_helper.rb +5 -3
  102. data/spec/spec_helpers/url_shared_behaviour.rb +5 -7
  103. metadata +32 -7
  104. data/lib/merb/caching/store/memcache.rb +0 -20
  105. data/lib/merb/mixins/form_control.rb +0 -332
  106. data/lib/patch +0 -69
  107. data/spec/merb/core_ext_spec.rb +0 -464
  108. data/spec/merb/form_control_mixin_spec.rb +0 -431
@@ -0,0 +1 @@
1
+ 1253
@@ -1,16 +1,19 @@
1
+ require 'rubygems'
2
+ Gem.clear_paths
3
+ Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
4
+
1
5
  require 'rake'
2
6
  require 'rake/rdoctask'
3
7
  require 'rake/testtask'
4
8
  require 'spec/rake/spectask'
5
9
  require 'fileutils'
6
- require 'rubygems'
7
10
 
8
- MERB_ENV = ENV['MERB_ENV'] if ENV['MERB_ENV']
11
+ Merb.environment = ENV['Merb.environment'] if ENV['Merb.environment']
9
12
  $RAKE_ENV = true
10
13
 
11
14
  require File.dirname(__FILE__)+'/config/boot.rb'
12
- require MERB_FRAMEWORK_ROOT+'/tasks'
13
- MERB_ROOT = File.dirname(__FILE__)
15
+ require Merb::framework_root+'/tasks'
16
+ Merb.root = File.dirname(__FILE__)
14
17
  include FileUtils
15
18
 
16
19
  # Get Merb plugins and dependencies
@@ -97,6 +100,19 @@ task :aok do
97
100
  sh %{rake spec}
98
101
  end
99
102
 
103
+ unless Gem.cache.search("haml").empty?
104
+ namespace :haml do
105
+ desc "Compiles all sass files into CSS"
106
+ task :compile_sass do
107
+ gem 'haml'
108
+ require 'sass'
109
+ puts "*** Updating stylesheets"
110
+ Sass::Plugin.update_stylesheets
111
+ puts "*** Done"
112
+ end
113
+ end
114
+ end
115
+
100
116
  ##############################################################################
101
117
  # SVN
102
118
  ##############################################################################
@@ -130,7 +130,7 @@
130
130
 
131
131
  <div class="header">
132
132
  <h1><%= @exception.name.humanize %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
133
- <% if show_details = ::Merb::Server.config[:exception_details] -%>
133
+ <% if show_details = ::Merb::Config[:exception_details] -%>
134
134
  <h2><%= @exception.message %></h2>
135
135
  <% else -%>
136
136
  <h2>Sorry about that...</h2>
@@ -1,6 +1,6 @@
1
1
  frozen_framework_path = File.join(File.dirname(__FILE__), "..", "framework")
2
2
 
3
- unless defined?(MERB_FRAMEWORK_ROOT)
3
+ unless defined?(Merb::framework_root)
4
4
  if File.directory?(frozen_framework_path)
5
5
  $:.unshift frozen_framework_path
6
6
  require File.join(frozen_framework_path, "merb")
@@ -1,9 +1,9 @@
1
1
  # Make the app's "gems" directory a place where gems are loaded from
2
2
  Gem.clear_paths
3
- Gem.path.unshift(MERB_ROOT / "gems")
3
+ Gem.path.unshift(Merb.root / "gems")
4
4
 
5
5
  # Make the app's "lib" directory a place where ruby files get "require"d from
6
- $LOAD_PATH.unshift(MERB_ROOT / "lib")
6
+ $LOAD_PATH.unshift(Merb.root / "lib")
7
7
 
8
8
  ### Merb doesn't come with database support by default. You need
9
9
  ### an ORM plugin. Install one, and uncomment one of the following lines,
@@ -34,7 +34,7 @@ use_test :rspec
34
34
  # OR
35
35
  # dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
36
36
 
37
- Merb::Server.after_app_loads do
37
+ Merb::BootLoader.after_app_loads do
38
38
  ### Add dependencies here that must load after the application loads:
39
39
 
40
40
  # dependency "magic_admin" # this gem uses the app's model classes
@@ -32,6 +32,10 @@
32
32
  # automatically in production mode.
33
33
  #:cache_templates: true
34
34
 
35
+ # Uncomment to bundle assets in dev mode. Assets are automatically bundled in
36
+ # production mode.
37
+ #:bundle_assets: true
38
+
35
39
  # this is true if you want mongrel to emulate the X-Sendfile header internally,
36
40
  # false if you want it to fall thru to apache or whatever front end server you use.
37
41
  # true by default
@@ -39,6 +43,7 @@
39
43
 
40
44
  # Uncomment and set this if you want to run a drb server for upload progress
41
45
  # or other drb services.
46
+ #:start_drb: true
42
47
  #:drb_server_port: 32323
43
48
 
44
49
  # If you want to protect some or all of your app with HTTP basic auth then
@@ -4,13 +4,13 @@ puts "Started merb_init.rb ..."
4
4
 
5
5
  # Your app's dependencies, including your database layer (if any) are defined
6
6
  # in config/dependencies.rb
7
- require File.join(MERB_ROOT, 'config', 'dependencies')
7
+ require File.join(Merb.root, 'config', 'dependencies')
8
8
 
9
9
  # Here's where your controllers, helpers, and models, etc. get loaded. If you
10
10
  # need to change the order of things, just move the call to 'load_application'
11
11
  # around this file.
12
12
  puts "Loading Application..."
13
- Merb::Server.load_application
13
+ Merb::BootLoader.load_application
14
14
 
15
15
  # Load environment-specific configuration
16
- require File.join(MERB_ROOT, 'config', 'environments', MERB_ENV)
16
+ require File.join(Merb.root, 'config', 'environments', Merb.environment)
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
3
 
4
+ def at_exit
5
+ end
6
+
4
7
  begin
5
8
  require 'rubigen'
6
9
  rescue LoadError
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  end
10
10
 
11
11
  require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
12
- require (APP_ROOT / "config" / "merb_init" )
12
+ require File.join(Merb.root, 'config', 'dependencies')
13
13
  module Kernel
14
14
  undef dependency if defined?(Kernel.dependency)
15
15
  end
@@ -1,7 +1,7 @@
1
- MERB_ENV="test"
1
+ Merb.environment="test"
2
2
  $TESTING=true
3
3
  require File.join(File.dirname(__FILE__), "..", 'config', 'boot')
4
- require File.join(MERB_ROOT, 'config', 'merb_init')
4
+ require File.join(Merb.root, 'config', 'merb_init')
5
5
 
6
6
  require 'merb/test/helper'
7
7
  require 'merb/test/rspec'
@@ -4,7 +4,7 @@ $TESTING=true
4
4
 
5
5
  require 'rubygems'
6
6
  require 'test/unit'
7
- require File.join(MERB_ROOT, 'config', 'merb_init')
7
+ require File.join(Merb.root, 'config', 'merb_init')
8
8
 
9
9
  require 'merb/test/helper'
10
10
 
@@ -4,6 +4,8 @@ class MerbPluginGenerator < RubiGen::Base
4
4
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5
5
  Config::CONFIG['ruby_install_name'])
6
6
 
7
+ default_options :shebang => DEFAULT_SHEBANG
8
+
7
9
 
8
10
  def initialize(args, runtime_options = {})
9
11
  super
@@ -31,6 +33,8 @@ class MerbPluginGenerator < RubiGen::Base
31
33
  m.template "sampleplugin_spec.rb", "spec/#{name}_spec.rb", :assigns => {:name => name}
32
34
  m.template "sampleplugin.rb", "lib/#{name}.rb", :assigns => {:name => name}
33
35
  m.template "merbtasks.rb", "lib/#{name}/merbtasks.rb", :assigns => {:name => name}
36
+
37
+ m.dependency "install_rubigen_scripts", [destination_root, "rubygems"], :shebang => options[:shebang]
34
38
  end
35
39
  end
36
40
 
data/bin/merb CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'rubygems'
4
3
  require 'merb/server'
5
-
6
- Merb::Server.run
4
+ Merb::Server.run
@@ -26,100 +26,163 @@ elsif ENV['PACKET']
26
26
  else
27
27
  require 'mongrel'
28
28
  end
29
+ require 'set'
29
30
  require 'fileutils'
30
31
  require 'merb/erubis_ext'
31
32
  require 'merb/logger'
33
+ require 'merb/version'
34
+ require 'merb/config'
32
35
 
33
- require 'set'
34
36
  autoload :MerbUploadHandler, 'merb/upload_handler'
35
37
  autoload :MerbHandler, 'merb/mongrel_handler'
36
38
 
37
- require 'merb/version'
38
-
39
39
  module Merb
40
- autoload :Authentication, 'merb/mixins/basic_authentication'
41
- autoload :ControllerMixin, 'merb/mixins/controller'
42
- autoload :ErubisCaptureMixin, 'merb/mixins/erubis_capture'
43
- autoload :FormControls, 'merb/mixins/form_control'
44
- autoload :RenderMixin, 'merb/mixins/render'
45
- autoload :ResponderMixin, 'merb/mixins/responder'
46
- autoload :ViewContextMixin, 'merb/mixins/view_context'
47
- autoload :WebControllerMixin, 'merb/mixins/web_controller'
40
+ autoload :AbstractController, 'merb/abstract_controller'
41
+ autoload :Assets, 'merb/assets'
42
+ autoload :Authentication, 'merb/mixins/basic_authentication'
43
+ autoload :Caching, 'merb/caching'
44
+ autoload :Const, 'merb/constants'
45
+ autoload :Controller, 'merb/controller'
46
+ autoload :ControllerExceptions, 'merb/exceptions'
47
+ autoload :ControllerMixin, 'merb/mixins/controller'
48
+ autoload :Dispatcher, 'merb/dispatcher'
49
+ autoload :DrbServiceProvider, 'drb_server'
50
+ autoload :ErubisCaptureMixin, 'merb/mixins/erubis_capture'
48
51
  autoload :GeneralControllerMixin, 'merb/mixins/general_controller'
49
- autoload :Caching, 'merb/caching'
50
- autoload :AbstractController, 'merb/abstract_controller'
51
- autoload :Const, 'merb/constants'
52
- autoload :Controller, 'merb/controller'
53
- autoload :Dispatcher, 'merb/dispatcher'
54
- autoload :DrbServiceProvider, 'drb_server'
55
- autoload :ControllerExceptions, 'merb/exceptions'
56
- autoload :MailController, 'merb/mail_controller'
57
- autoload :Mailer, 'merb/mailer'
58
- autoload :PartController, 'merb/part_controller'
59
- autoload :Request, 'merb/request'
60
- autoload :Router, 'merb/router'
61
- autoload :Server, 'merb/server'
62
- autoload :UploadProgress, 'merb/upload_progress'
63
- autoload :ViewContext, 'merb/view_context'
64
- autoload :SessionMixin, 'merb/session'
65
- autoload :Template, 'merb/template'
66
- autoload :Plugins, 'merb/plugins'
67
- autoload :Rack,'merb/rack_adapter'
68
-
69
- # Set up Merb::Server.config[] as an accessor for @@merb_opts
70
- class Server
71
- class << self
72
- def config() @@merb_opts ||= {} end
73
- end
74
- end
52
+ autoload :InlinePartialMixin, 'merb/mixins/inline_partial'
53
+ autoload :MailController, 'merb/mail_controller'
54
+ autoload :Mailer, 'merb/mailer'
55
+ autoload :PartController, 'merb/part_controller'
56
+ autoload :Plugins, 'merb/plugins'
57
+ autoload :Rack, 'merb/rack_adapter'
58
+ autoload :RenderMixin, 'merb/mixins/render'
59
+ autoload :Request, 'merb/request'
60
+ autoload :ResponderMixin, 'merb/mixins/responder'
61
+ autoload :Router, 'merb/router'
62
+ autoload :Server, 'merb/server'
63
+ autoload :SessionMixin, 'merb/session'
64
+ autoload :Template, 'merb/template'
65
+ autoload :UploadProgress, 'merb/upload_progress'
66
+ autoload :ViewContext, 'merb/view_context'
67
+ autoload :ViewContextMixin, 'merb/mixins/view_context'
68
+ autoload :WebControllerMixin, 'merb/mixins/web_controller'
75
69
 
70
+ # This is where Merb-global variables are set and held
71
+ class << self
72
+ def environment
73
+ @environment
74
+ end
75
+
76
+ def environment=(value)
77
+ @environment ||= value
78
+ end
79
+
80
+ def load_paths
81
+ [ "/app/models/**/*.rb",
82
+ "/app/controllers/application.rb",
83
+ "/app/controllers/**/*.rb",
84
+ "/app/helpers/**/*.rb",
85
+ "/app/mailers/**/*.rb",
86
+ "/app/parts/**/*.rb",
87
+ "/config/router.rb"
88
+ ]
89
+ end
90
+
91
+ # Application paths
92
+ def root
93
+ @root || Merb::Config[:merb_root] || Dir.pwd
94
+ end
95
+
96
+ def root_path(*path)
97
+ File.join(root, *path)
98
+ end
99
+
100
+ def view_path
101
+ root_path 'app/views'
102
+ end
103
+
104
+ def model_path
105
+ root_path 'app/models'
106
+ end
107
+
108
+ def application_controller_path
109
+ root_path 'app/controllers/application.rb'
110
+ end
111
+
112
+ def controller_path
113
+ root_path 'app/controllers'
114
+ end
115
+
116
+ def helper_path
117
+ root_path 'app/helpers'
118
+ end
119
+
120
+ def mailer_path
121
+ root_path 'app/mailers'
122
+ end
123
+
124
+ def part_path
125
+ root_path 'app/parts'
126
+ end
127
+
128
+ def router_path
129
+ root_path '/config/router.rb'
130
+ end
131
+
132
+ def root=(value)
133
+ @root ||= value
134
+ end
135
+
136
+
137
+ # Logger settings
138
+ attr :logger, true
139
+
140
+ def log_path
141
+ if $TESTING
142
+ "#{Merb.root}/log/merb_test.log"
143
+ elsif !(Merb::Config[:daemonize] || Merb::Config[:cluster] )
144
+ STDOUT
145
+ else
146
+ "#{Merb.root}/log/merb.#{Merb::Config[:port]}.log"
147
+ end
148
+ end
149
+
150
+ # Framework paths
151
+
152
+ def framework_root
153
+ @framework_root ||= File.dirname(__FILE__)
154
+ end
155
+
156
+ def framework_path(path)
157
+ File.join(framework_root, path)
158
+ end
159
+
160
+ def lib_path
161
+ framework_path 'merb'
162
+ end
163
+
164
+ def skeleton_path
165
+ framework_path '../app_generators/merb/templates'
166
+ end
167
+ end
168
+
76
169
  # Set up default generator scope
77
170
  GENERATOR_SCOPE = [:merb_default, :merb, :rspec]
78
171
  end
79
172
 
80
- def __DIR__; File.dirname(__FILE__); end
81
- lib = File.join(__DIR__, 'merb')
82
- require File.join(__DIR__, 'merb/core_ext')
173
+ # Load up the core extensions
174
+ require Merb.framework_path('merb/core_ext')
175
+ require Merb.framework_path('merb/version')
83
176
 
84
- unless Object.const_defined?('MERB_ENV')
85
- MERB_ENV = Merb::Server.config[:environment].nil? ? ($TESTING ? 'test' : 'development') : Merb::Server.config[:environment]
86
- end
177
+ # Set the environment
178
+ Merb.environment = Merb::Config[:environment] || ($TESTING ? 'test' : 'development')
87
179
 
88
- MERB_FRAMEWORK_ROOT = __DIR__
89
- MERB_ROOT = Merb::Server.config[:merb_root] || Dir.pwd
90
- MERB_VIEW_ROOT = MERB_ROOT / "app/views"
91
- MERB_SKELETON_DIR = File.join(MERB_FRAMEWORK_ROOT, '../app_generators/merb/templates')
92
- logpath = if $TESTING
93
- "#{MERB_ROOT}/log/merb_test.log"
94
- elsif !(Merb::Server.config[:daemonize] || Merb::Server.config[:cluster] )
95
- STDOUT
96
- else
97
- "#{MERB_ROOT}/log/merb.#{Merb::Server.config[:port]}.log"
98
- end
99
- FileUtils.mkdir_p(File.dirname(logpath)) if logpath.is_a?(String)
100
- MERB_LOGGER = Merb::Logger.new(logpath)
101
- MERB_LOGGER.level = Merb::Logger.const_get(Merb::Server.config[:log_level].upcase) rescue Merb::Logger::INFO
102
- MERB_PATHS = [
103
- "/app/models/**/*.rb",
104
- "/app/controllers/application.rb",
105
- "/app/controllers/**/*.rb",
106
- "/app/helpers/**/*.rb",
107
- "/app/mailers/**/*.rb",
108
- "/app/parts/**/*.rb",
109
- "/config/router.rb"
110
- ]
111
-
112
- if $TESTING
113
- test_files = File.join(lib, 'test', '*.rb')
114
- Dir[test_files].each { |file| require file }
115
- end
116
-
117
- # If we're in the TEST environment or if running from Rake make sure to load
118
- # config/merb.yml - which is normally done by Merb::Server.run
119
- Merb::Server.load_config if $TESTING || $RAKE_ENV
180
+ # Create and setup the logger
181
+ Merb.logger = Merb::Logger.new(Merb.log_path)
182
+ Merb.logger.level = Merb::Logger.const_get(Merb::Config[:log_level].upcase) rescue Merb::Logger::INFO
120
183
 
121
184
  # If you don't use the JSON gem, disable auto-parsing of json params too
122
- if Merb::Server.config[:disable_json_gem]
185
+ if Merb::Config[:disable_json_gem]
123
186
  Merb::Request::parse_json_params = false
124
187
  else
125
188
  begin
@@ -128,4 +191,9 @@ else
128
191
  puts "Using pure ruby JSON lib"
129
192
  require 'json/pure'
130
193
  end
194
+ end
195
+
196
+ if $TESTING
197
+ test_files = File.join(Merb.lib_path, 'test', '*.rb')
198
+ Dir[test_files].each { |file| require file }
131
199
  end
@@ -80,10 +80,11 @@ module Merb
80
80
 
81
81
  def call_action(action)
82
82
  # [[:id], [:foo, 7]]
83
- args = self.class.action_argument_list[action.to_sym].map do |arg, default|
84
- raise BadRequest unless params[arg.to_sym] || default
85
- params[arg.to_sym] || default
86
- end
83
+ args = self.class.action_argument_list[action.to_sym].map do |arg_default|
84
+ arg = arg_default[0]
85
+ raise BadRequest unless params.key?(arg.to_sym) || (arg_default.size == 2)
86
+ params.key?(arg.to_sym) ? params[arg.to_sym] : arg_default[1]
87
+ end rescue []
87
88
  send(action, *args)
88
89
  end
89
90
 
@@ -262,7 +263,7 @@ module Merb
262
263
  'You can only skip filters that have a String or Symbol name.'
263
264
  ) unless [Symbol, String].include? filter.class
264
265
 
265
- MERB_LOGGER.warn("Filter #{filter} was not found in your filter chain."
266
+ Merb.logger.warn("Filter #{filter} was not found in your filter chain."
266
267
  ) unless filters.reject! {|f| f.first.to_s[filter.to_s] }
267
268
  end
268
269