Sha256: 5c138676ede4b4bfe26eb5a3507ef51648d9aadb3e38aad90a0db162e32966f5

Contents?: true

Size: 975 Bytes

Versions: 18

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActionController::RespondWithMatcher do
  statuses = { :success => 200, :redirect => 301, :missing => 404, :error => 500,
    :not_implemented => 501 }

  statuses.each do |human_name, numeric_code|
    context "a controller responding with #{human_name}" do
      it 'accepts responding with a numeric response code' do
        controller_with_status(numeric_code).should respond_with(numeric_code)
      end

      it 'accepts responding with a symbol response code' do
        controller_with_status(numeric_code).should respond_with(human_name)
      end

      it 'rejects responding with another status' do
        another_status = statuses.except(human_name).keys.first

        controller_with_status(numeric_code).
          should_not respond_with(another_status)
      end
    end
  end

  def controller_with_status(status)
    build_response do
      render :text => 'text', :status => status
    end
  end
end

Version data entries

18 entries across 17 versions & 2 rubygems

Version Path
shoulda-matchers-2.5.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.4.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.4.0.rc1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.3.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
challah-1.0.0 vendor/bundle/gems/shoulda-matchers-2.2.0/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.2.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-2.1.0/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.1.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
challah-1.0.0.beta2 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.0.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.6 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.5 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.4 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.2 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-1.5.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb