Sha256: 51a83f3b924cf6e27fecaef600d96fa880d70f64cf683df683f24159dff4063e

Contents?: true

Size: 995 Bytes

Versions: 12

Compression:

Stored size: 995 Bytes

Contents

require 'unit_spec_helper'

describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller 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
        expect(controller_with_status(numeric_code)).to respond_with(numeric_code)
      end

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

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

        expect(controller_with_status(numeric_code)).
          not_to respond_with(another_status)
      end
    end
  end

  def controller_with_status(status)
    build_fake_response do
      render text: 'text', status: status
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
shoulda-matchers-3.1.3 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-4.0.0.rc1 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.1.2 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.1.1 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.1.0 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.0.1 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.0.0 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-3.0.0.rc1 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb