Sha256: 64c7f41156059922a55726d44bb5c2574d29689ba56c59233b61ac2815d61233

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActionController::RespondWithContentTypeMatcher do
  it 'generates the correct description' do
    expected = 'respond with content type of application/xml'

    respond_with_content_type(:xml).description.should == expected
  end

  it 'accepts responding with content type as symbol' do
    xml_controller.should respond_with_content_type(:xml)
  end

  it 'accepts responding with qualified MIME-style content type' do
    xml_controller.should respond_with_content_type('application/xml')
  end

  it 'accepts responding with a regex matching the content type' do
    xml_controller.should respond_with_content_type(/xml/)
  end

  it 'rejects responding with another content type' do
    xml_controller.should_not respond_with_content_type(:json)
  end

  def xml_controller
    build_response do
      render :xml => { :user => 'thoughtbot' }.to_xml
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoulda-kept-respond-with-content-type-1.1.0 spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb
shoulda-kept-respond-with-content-type-1.0.0 spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb