Sha256: dce00dd0ebc5a025f34c806e064e0f1511dfa7bf7b6c382f931f8a9af53ac85d

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "mime type responders", :type => :controller do
  setup = lambda {
    class PiratesController < ActionController::Base
      expose_many(:pirates)
    end
  }
  setup.call
    
  ActionController::Routing::Routes.draw do |map| 
    map.resources :pirates, :collection => {:test => :any}
  end

  controller_name :pirates
  Object.remove_class(PiratesController)
  
  before(:each) do
    setup.call
    @controller = PiratesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    @pirate = Factory.stub(:pirate)
    Pirate.stub(:new => @pirate)
  end
  
  after(:each) do
    Object.remove_class(PiratesController)
  end
  
  it "should respond with not acceptable if no acceptable mime type is not found" do
    @request.accept = "application/x-yaml"
    @pirate.stub(:save => true)
    post(:create)        
    should respond_with(:not_acceptable)
  end
  
  it "should respond with mime type when header is set" do
    @request.accept = 'application/xml'
    @pirate.stub(:save => true)
    post(:create)        
    should respond_with_content_type(:xml) 
  end
  
  it "should respond with mime type when params[:format] is set" do
    @pirate.stub(:save => true)
    post(:create, {:format => 'xml'})            
    should respond_with_content_type(:xml) 
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/responders/respond_to_mime_types_spec.rb
exposure-0.2.0 spec/responders/respond_to_mime_types_spec.rb
exposure-0.1.3 spec/responders/respond_to_mime_types_spec.rb
exposure-0.1.2 spec/responders/respond_to_mime_types_spec.rb
exposure-0.1.1 spec/responders/respond_to_mime_types_spec.rb
exposure-0.1.0 spec/responders/respond_to_mime_types_spec.rb
exposure-0.0.7 spec/responders/respond_to_mime_types_spec.rb