Sha256: 479cae11405f1953cff7e97032e099acf3a30c184db93db0ba499afdaa1ec88e

Contents?: true

Size: 971 Bytes

Versions: 8

Compression:

Stored size: 971 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
        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

8 entries across 8 versions & 2 rubygems

Version Path
shoulda-matchers-2.7.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.6.2 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
mcmire-shoulda-matchers-2.6.2.docs.1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
mcmire-shoulda-matchers-2.6.1.docs.1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.6.1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.6.1.rc2 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.6.1.rc1 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
shoulda-matchers-2.6.0 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb