spec/grape/middleware/formatter_spec.rb in grape-1.2.4 vs spec/grape/middleware/formatter_spec.rb in grape-1.2.5

- old
+ new

@@ -211,11 +211,17 @@ end context 'no content responses' do let(:no_content_response) { ->(status) { [status, {}, ['']] } } - Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.each do |status| + STATUSES_WITHOUT_BODY = if Gem::Version.new(Rack.release) >= Gem::Version.new('2.1.0') + Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.keys + else + Rack::Utils::STATUS_WITH_NO_ENTITY_BODY + end + + STATUSES_WITHOUT_BODY.each do |status| it "does not modify a #{status} response" do expected_response = no_content_response[status] allow(app).to receive(:call).and_return(expected_response) expect(subject.call({})).to eq(expected_response) end @@ -388,9 +394,13 @@ end let(:app) { ->(_env) { [200, {}, ['']] } } before do Grape::Formatter.register :invalid, InvalidFormatter Grape::ContentTypes::CONTENT_TYPES[:invalid] = 'application/x-invalid' + end + after do + Grape::ContentTypes::CONTENT_TYPES.delete(:invalid) + Grape::Formatter.default_elements.delete(:invalid) end it 'returns response by invalid formatter' do env = { 'PATH_INFO' => '/hello.invalid', 'HTTP_ACCEPT' => 'application/x-invalid' } _, _, bodies = *subject.call(env)