Changeset 791
- Timestamp:
- 10/28/07 22:27:00 (1 year ago)
- Files:
-
- branches/ivey_unhosing/lib/merb/abstract_controller.rb (modified) (1 diff)
- branches/ivey_unhosing/lib/merb/mixins/render.rb (modified) (4 diffs)
- branches/ivey_unhosing/lib/merb/mixins/responder.rb (modified) (4 diffs)
- branches/ivey_unhosing/spec/fixtures/controllers/render_spec_controllers.rb (modified) (2 diffs)
- branches/ivey_unhosing/spec/fixtures/mailers/views/layout/application.erb (deleted)
- branches/ivey_unhosing/spec/fixtures/mailers/views/layout/application.html.erb (copied) (copied from trunk/spec/fixtures/mailers/views/layout/application.erb)
- branches/ivey_unhosing/spec/fixtures/parts/views/layout/todo_part.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/parts/views/layout/todo_part.html.erb (copied) (copied from trunk/spec/fixtures/parts/views/layout/todo_part.herb)
- branches/ivey_unhosing/spec/fixtures/parts/views/layout/todo_part.xml.erb (added)
- branches/ivey_unhosing/spec/fixtures/parts/views/todo_part/list.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/parts/views/todo_part/list.html.erb (copied) (copied from trunk/spec/fixtures/parts/views/todo_part/list.herb)
- branches/ivey_unhosing/spec/fixtures/views/erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/examples/_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/_erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/examples/_erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/examples/_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/_haml.html.haml (copied) (copied from trunk/spec/fixtures/views/examples/_haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/examples/_markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/examples/_markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/examples/_markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/_throw_content.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/_throw_content.html.erb (copied) (copied from trunk/spec/fixtures/views/examples/_throw_content.herb)
- branches/ivey_unhosing/spec/fixtures/views/examples/hello.xerb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/hello.xml.builder (copied) (copied from trunk/spec/fixtures/views/examples/hello.xerb)
- branches/ivey_unhosing/spec/fixtures/views/examples/js.jerb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/js.js.erb (copied) (copied from trunk/spec/fixtures/views/examples/js.jerb)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_catch_content.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_catch_content.html.erb (copied) (copied from trunk/spec/fixtures/views/examples/template_catch_content.herb)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_catch_content_from_partial.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb (copied) (copied from trunk/spec/fixtures/views/examples/template_catch_content_from_partial.herb)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_throw_content.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/examples/template_throw_content.html.erb (copied) (copied from trunk/spec/fixtures/views/examples/template_throw_content.herb)
- branches/ivey_unhosing/spec/fixtures/views/exceptions/admin_access_required.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/exceptions/admin_access_required.html.erb (copied) (copied from trunk/spec/fixtures/views/exceptions/admin_access_required.herb)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_builder.builder (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis.jerb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis.xerb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis2.rhtml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis2.rxml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis3.builder (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_erubis3.erb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/extension_template_controller/old_style_markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/haml.html.haml (copied) (copied from trunk/spec/fixtures/views/haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/layout/application.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/layout/application.html.erb (copied) (copied from trunk/spec/fixtures/views/layout/application.herb)
- branches/ivey_unhosing/spec/fixtures/views/layout/application.xml.erb (added)
- branches/ivey_unhosing/spec/fixtures/views/layout/nested/example.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/layout/nested/example.html.erb (copied) (copied from trunk/spec/fixtures/views/layout/nested/example.herb)
- branches/ivey_unhosing/spec/fixtures/views/markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/nested/example/test.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/nested/example/test.html.erb (copied) (copied from trunk/spec/fixtures/views/nested/example/test.herb)
- branches/ivey_unhosing/spec/fixtures/views/partials/_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/partials/_erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/partials/_erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/partials/_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/partials/_haml.html.haml (copied) (copied from trunk/spec/fixtures/views/partials/_haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/partials/_markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/partials/_markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/partials/_markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/template_views/interface__buffer_erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_haml.html.haml (copied) (copied from trunk/spec/fixtures/views/template_views/interface__buffer_haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/template_views/interface__buffer_markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface__buffer_markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/template_views/interface_capture_erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_haml.html.haml (copied) (copied from trunk/spec/fixtures/views/template_views/interface_capture_haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/template_views/interface_capture_markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_capture_markaby.mab (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_erubis.herb (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_erubis.html.erb (copied) (copied from trunk/spec/fixtures/views/template_views/interface_concat_erubis.herb)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_haml.haml (deleted)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_haml.html.haml (copied) (copied from trunk/spec/fixtures/views/template_views/interface_concat_haml.haml)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_markaby.html.mab (copied) (copied from trunk/spec/fixtures/views/template_views/interface_concat_markaby.mab)
- branches/ivey_unhosing/spec/fixtures/views/template_views/interface_concat_markaby.mab (deleted)
- branches/ivey_unhosing/spec/merb/render_spec.rb (modified) (7 diffs)
- branches/ivey_unhosing/spec/merb/responder_spec.rb (modified) (13 diffs)
- branches/ivey_unhosing/spec/spec_helper.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ivey_unhosing/lib/merb/abstract_controller.rb
r769 r791 199 199 end 200 200 201 201 202 def content_type 203 params[:format] 204 end 202 205 end 203 206 branches/ivey_unhosing/lib/merb/mixins/render.rb
r786 r791 27 27 # 28 28 # Merb::Template::Haml 29 #30 # Erubis template ext: .erb31 # Markaby template ext: .mab32 # Builder template ext: .builder33 # Haml template ext: .haml34 29 # 35 30 # In addition, you can identify the type of output with an … … 378 373 extensions = Template::EXTENSIONS.keys 379 374 glob = "#{path}.#{@_template_format}.{#{opts[:ext] || extensions.join(",")}}" 380 glob_old = old_style_template_glob(path, extensions, opts) 381 Dir[glob].first || Dir[glob_old].first || (@_merb_unmatched = glob << "<br/>Or on the old scheme<br/>" << glob_old; nil) 375 Dir[glob].first || (@_merb_unmatched = glob; nil) 382 376 end 383 377 … … 385 379 # request of the developer. 386 380 def choose_template_format(types, opts) 387 opts[:format] ||= (content_type_set? ? content_type : params[:format] )381 opts[:format] ||= content_type 388 382 @_template_format = [(opts.keys & types.keys)].flatten.first # Check for render :js => etc 389 383 @_template_format ||= opts[:format] || :html … … 406 400 end 407 401 408 # this method is to support the old style of extensions.409 # the newer template.format.engine should take it's place410 def old_style_template_glob(path, extensions, opts) #:nodoc:411 ext = []412 case opts[:format]413 when :js414 ext << %w(jerb)415 when :xml416 ext << %w(xerb rxml builder)417 when :html418 ext << %w(herb rhtml erb)419 end420 out = "#{path}.{#{(opts[:ext] || ext << extensions).join(",")}}"421 end422 402 end 423 403 end branches/ivey_unhosing/lib/merb/mixins/responder.rb
r784 r791 79 79 module ResponderMixin 80 80 81 def respond_to(&block)82 responder = Rest::Responder.new(request.accept, params)83 block.call(responder)84 responder.respond(headers)85 @_status = responder.status if responder.status86 responder.body87 end88 89 def determine_content_type81 # def respond_to(&block) 82 # responder = Rest::Responder.new(request.accept, params) 83 # block.call(responder) 84 # responder.respond(headers) 85 # @_status = responder.status if responder.status 86 # responder.body 87 # end 88 89 def perform_content_negotiation 90 90 raise Merb::ControllerExceptions::NotAcceptable if provided_formats.empty? 91 91 if fmt = params[:format] … … 114 114 115 115 def content_type 116 @_content_type ||= determine_content_type 116 unless content_type_set? 117 @_content_type = perform_content_negotiation 118 raise Merb::ControllerExceptions::NotAcceptable.new("Unknown content_type for response: #{@_content_type}") unless 119 Merb.available_mime_types.has_key?(@_content_type) 120 headers['Content-Type'] = Merb.available_mime_types[@_content_type].first 121 end 122 @_content_type 117 123 end 118 124 … … 129 135 class Responder 130 136 131 attr_reader :body, :type, :status132 133 def initialize(accept_header, params={})134 MERB_LOGGER.info accept_header135 @accepts = Responder.parse(accept_header)136 @params = params137 @stack = {}138 end139 140 def method_missing(symbol, &block)141 raise "respond_to expects a block" unless block_given?142 # the first method we encounter here will be used for the catch all mime-type */*143 @default_content_type ||= symbol144 @stack[symbol] = block145 end146 147 def respond(headers)148 unless @stack.keys.all?{|k| TYPES.has_key?(k) }149 raise "unrecognized mime type in respond_to block"150 end151 mime_type = negotiate_content152 if mime_type153 headers['Content-Type'] = mime_type.super_range154 @params[:format] = mime_type.to_sym155 @body = @stack[mime_type.to_sym].call156 else157 raise ControllerExceptions::NotAcceptable158 end159 end160 161 137 protected 162 138 … … 177 153 end 178 154 179 private180 181 def negotiate_content182 if @params[:format]183 negotiate_by_format184 elsif @accepts.first.to_sym == :all || (@stack.keys & @accepts.map(&:to_sym)).size > 0185 negotiate_by_accept_header186 end187 end188 189 def negotiate_by_format190 format = @params[:format].to_sym191 if @stack[format]192 if @accepts.map {|a| a.to_sym }.include?(format)193 @accepts.detect{|a| a.to_sym == format }194 else195 AcceptType.new(TYPES[format].first,0)196 end197 end198 end199 200 def negotiate_by_accept_header201 @accepts.each do |accept|202 if accept.to_sym == :all203 if @default_content_type204 return AcceptType.new(TYPES[@default_content_type].first,0)205 else206 raise "no formats specified in respond_to block"207 end208 end209 return accept if @stack[accept.to_sym]210 end211 end212 213 155 end 214 156 branches/ivey_unhosing/spec/fixtures/controllers/render_spec_controllers.rb
r784 r791 11 11 12 12 # Fake class so we can render subdirectories of views 13 class Examples < Merb::Controller; end 13 class Examples < Merb::Controller; 14 end 14 15 15 16 module Nested … … 47 48 48 49 class ExtensionTemplateController < Merb::Controller 50 provides :js, :xml 49 51 def erubis_templates 50 respond_to do |format| 51 format.html { render } 52 format.js { render } 53 format.xml { render } 54 end 52 render 55 53 end 56 54 57 55 def haml_templates 58 respond_to do |format| 59 format.html { render } 60 format.js { render } 61 format.xml { render } 62 end 56 render 63 57 end 64 58 65 59 def markaby_templates 66 respond_to do |format| 67 format.html { render } 68 format.js { render } 69 format.xml { render } 70 end 60 render 71 61 end 72 62 73 63 def old_style_erubis 74 respond_to do |format| 75 format.html { render } 76 format.js { render } 77 format.xml { render } 78 end 64 render 79 65 end 80 66 81 67 def old_style_erubis2 82 respond_to do |format| 83 format.html { render } 84 format.js { render } 85 format.xml { render } 86 end 68 render 87 69 end 88 70 89 71 def old_style_erubis3 90 respond_to do |format| 91 format.html { render } 92 format.xml { render } 93 end 72 render 94 73 end 95 74 96 75 def old_style_haml 97 respond_to do |format| 98 format.html { render } 99 format.js { render } 100 format.xml { render } 101 end 76 render 102 77 end 103 78 104 79 def old_style_markaby 105 respond_to do |format| 106 format.html { render } 107 format.js { render } 108 format.xml { render } 109 end 80 render 110 81 end 111 82 112 83 def old_style_builder 113 respond_to do |format| 114 format.html { render } 115 format.js { render } 116 format.xml { render } 117 end 84 render 118 85 end 119 86 branches/ivey_unhosing/spec/merb/render_spec.rb
r784 r791 50 50 lambda { 51 51 c.render_no_layout(:template => nil) 52 }.should raise_error( Exception, "called find_template without an :action or :layout")52 }.should raise_error(Merb::ControllerExceptions::TemplateNotFound) 53 53 end 54 54 … … 146 146 c = new_controller 147 147 content = c.render(:template => "erubis") 148 c.template.should == "erubis.h erb"148 c.template.should == "erubis.html.erb" 149 149 end 150 150 … … 185 185 c.template.should == "erubis_templates.xml.erb" 186 186 end 187 188 it "should provide backwards compatibility and render old_style_erubis.herb" do189 c = new_spec_controller(:format => 'html')190 c.dispatch(:old_style_erubis)191 c.template.should == "old_style_erubis.herb"192 end193 194 it "should provide backwards compatibility and render old_syle_erubis.jerb" do195 c = new_spec_controller(:format => 'js')196 c.dispatch(:old_style_erubis)197 c.template.should == "old_style_erubis.jerb"198 end199 200 it "should provide backwards compatibility and render old_style_erubis2.rhtml" do201 c = new_spec_controller(:format => 'html')202 c.dispatch(:old_style_erubis2)203 c.template.should == "old_style_erubis2.rhtml"204 end205 206 it "should provide backwards compatibility and render old_style_erubis3.rhtml" do207 c = new_spec_controller(:format => 'html')208 c.dispatch(:old_style_erubis3)209 c.template.should == "old_style_erubis3.erb"210 end211 187 212 188 it "should render js in nested partials when the format is javascript" do … … 222 198 end 223 199 224 # it "should render js with .rhtml" do225 # c = new_spec_controller(:format => 'js')226 # c.dispatch(:old_style_erubis2)227 # c.template.should == "old_style_erubis2.rhtml"228 # end229 230 200 end 231 201 … … 256 226 c.dispatch(:markaby_templates) 257 227 c.template.should == "markaby_templates.xml.mab" 258 end259 260 it "should render all actions with .mab" do261 %w( html js xml ).each do |format|262 c = new_spec_controller(:format => format)263 c.dispatch(:old_style_markaby)264 c.template.should == "old_style_markaby.mab"265 end266 228 end 267 229 end … … 297 259 end 298 260 299 it "should render all actions with .haml" do300 %w( html js xml ).each do |format|301 c = new_spec_controller(:format => format)302 c.dispatch(:old_style_haml)303 c.template.should == "old_style_haml.haml"304 end305 end306 261 end 307 262 … … 323 278 end 324 279 325 it "should render all actions with .builder" do326 %w( html js xml ).each do |format|327 c = new_spec_controller(:format => format)328 c.dispatch(:old_style_builder)329 c.template.should == "old_style_builder.builder"330 end331 end332 333 it "should provide backwards compatibility and render old_style_erubis.xerb" do334 c = new_spec_controller(:format => "xml")335 c.dispatch(:old_style_erubis)336 c.template.should == "old_style_erubis.xerb"337 end338 339 it "should provide backwards compatibility and render old_style_erubis2.rxml" do340 c = new_spec_controller(:format => "xml")341 c.dispatch(:old_style_erubis2)342 c.template.should == "old_style_erubis2.rxml"343 end344 345 it "should provide backwards compatibility and render old_style_erubis3.rxml" do346 c = new_spec_controller(:format => "xml")347 c.dispatch(:old_style_erubis3)348 c.template.should == "old_style_erubis3.builder"349 end350 280 end 351 281 end branches/ivey_unhosing/spec/merb/responder_spec.rb
r784 r791 224 224 225 225 class ResponderSpecController < Merb::Controller 226 227 226 def index 228 respond_to do |format| 229 format.html { "html" } 230 format.xml { "xml" } 231 format.yaml { "yaml" } 232 end 227 only_provides :html, :xml, :yaml 228 content_type.to_s 233 229 end 234 230 235 231 def create 236 respond_to do |format| 237 format.xml { render :nothing => 201 } 238 end 239 end 240 232 only_provides :xml 233 render :nothing => 201 234 end 241 235 end 242 236 243 237 class CrazyResponderSpecController < Merb::Controller 244 245 238 def index 246 respond_to do |format| 247 format.donkey { "donkey" } 248 end 249 end 250 251 end 252 253 class RespondToVsNoRespondToController < Merb::Controller 254 255 def with_respond_to 256 respond_to do |type| 257 type.html { "a response" } 258 end 259 end 260 261 def without_respond_to 262 "a response" 263 end 239 only_provides :donkey 240 content_type 241 "donkey" 242 end 264 243 end 265 244 … … 325 304 end 326 305 327 it "should raise runtime error when respond_totype is not in TYPES" do306 it "should raise 406 when negotiated type is not in TYPES" do 328 307 r = Merb::Test::FakeRequest.new 329 308 c = CrazyResponderSpecController.build(r, r.body) 330 lambda{c.dispatch(:index)}.should raise_error(RuntimeError) 331 end 332 333 it "should return the same whether respond_to is used or not and Accept is */*" do 334 r1 = Merb::Test::FakeRequest.new(:http_accept => '*/*') 335 c1 = RespondToVsNoRespondToController.build(r1, r1.body) 336 c1.dispatch(:without_respond_to) 337 r2 = Merb::Test::FakeRequest.new(:http_accept => '*/*') 338 c2 = RespondToVsNoRespondToController.build(r2, r2.body) 339 c2.dispatch(:with_respond_to) 340 c1.headers['Content-Type'].should == c2.headers['Content-Type'] 341 end 342 309 lambda{c.dispatch(:index)}.should raise_error(Merb::ControllerExceptions::NotAcceptable) 310 end 311 343 312 it "should call the block for the supported response type yaml" do 344 313 c = new_responder_spec_controller(:http_accept => 'text/yaml') … … 387 356 ResponderSpecController.build(@request, @request.body) 388 357 end 389 390 358 end 391 359 … … 404 372 end 405 373 406 it "should have a determine_content_type" do407 @responder.should respond_to(: determine_content_type)374 it "should have a perform_content_negotiation" do 375 @responder.should respond_to(:perform_content_negotiation) 408 376 end 409 377 … … 412 380 @responder.should_receive(:provided_formats). 413 381 at_least(:once).and_return([:html]) 414 @responder. determine_content_type382 @responder.perform_content_negotiation 415 383 end 416 384 … … 418 386 @responder.should_receive(:provided_formats). 419 387 at_least(:once).and_return([:html]) 420 @responder. determine_content_type388 @responder.perform_content_negotiation 421 389 end 422 390 … … 424 392 @responder.should_receive(:params).at_least(:once). 425 393 and_return({:format => "html"}) 426 @responder. determine_content_type394 @responder.perform_content_negotiation 427 395 end 428 396 … … 431 399 @responder.should_receive(:request).once.and_return(@request) 432 400 @request.should_receive(:accept).once.and_return("text/html") 433 @responder. determine_content_type401 @responder.perform_content_negotiation 434 402 end 435 403 436 404 it "should not use request.accept when params[:format] is not nil" do 437 405 @responder.should_receive(:request).exactly(0).times 438 @responder. determine_content_type406 @responder.perform_content_negotiation 439 407 end 440 408 441 409 it "should return :html when params[:format] = :html" do 442 @responder. determine_content_type.should == :html410 @responder.perform_content_negotiation.should == :html 443 411 end 444 412 … … 446 414 @responder.should_receive(:provided_formats).at_least(:once). 447 415 and_return([:xml]) 448 lambda {@responder. determine_content_type}.should raise_error(Merb::ControllerExceptions::NotAcceptable)416 lambda {@responder.perform_content_negotiation}.should raise_error(Merb::ControllerExceptions::NotAcceptable) 449 417 end 450 418 … … 453 421 @responder.stub!(:params).and_return({}) 454 422 @request.should_receive(:accept).once.and_return("*/*") 455 @responder. determine_content_type.should == :xml423 @responder.perform_content_negotiation.should == :xml 456 424 end 457 425 … … 460 428 @responder.stub!(:params).and_return({}) 461 429 @request.should_receive(:accept).once.and_return("text/xml, text/html") 462 @responder. determine_content_type.should == :xml430 @responder.perform_content_negotiation.should == :xml 463 431 end 464 432 … … 467 435 @responder.stub!(:params).and_return({}) 468 436 @request.should_receive(:accept).once.and_return("text/xml, text/json") 469 lambda {@responder. determine_content_type}.should raise_error(Merb::ControllerExceptions::NotAcceptable)437 lambda {@responder.perform_content_negotiation}.should raise_error(Merb::ControllerExceptions::NotAcceptable) 470 438 end 471 439 … … 474 442 @responder.should_receive(:params).exactly(0).times 475 443 @responder.should_receive(:request).exactly(0).times 476 lambda {@responder. determine_content_type}.should raise_error(Merb::ControllerExceptions::NotAcceptable)444 lambda {@responder.perform_content_negotiation}.should raise_error(Merb::ControllerExceptions::NotAcceptable) 477 445 end 478 446 end branches/ivey_unhosing/spec/spec_helper.rb
r627 r791 24 24 request.params.update(additional_params) 25 25 request.cookies = {} 26 request.accept ||= '*/*' 26 27 27 28 yield request if block_given?
