<commit_before>require 'spec_helper'
describe CSV2API::Server do
  include Rack::Test::Methods

  def app
    CSV2API::Server
  end

  describe '/tasks' do
    context 'when called with .json extension' do
      it 'returns tasks.csv in json' do
        get '/tasks'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = json(last_response.body).first
        expect(parsed_response).to be_a(Hash)
      end
    end

    context 'when called with .xml extension' do
      it 'returns tasks.csv in XML' do
        get '/tasks.xml'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = xml(last_response.body)
        expect(parsed_response).to be_a(Hash)
      end
    end
  end

  describe '/transaction' do
    context 'when called without .json extension' do
      it 'returns transaction.csv in json' do
        get '/transaction'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = json(last_response.body).first
        expect(parsed_response).to be_a(Hash)
      end
    end

    context 'when called with .xml extension' do
      it 'returns transaction.csv in XML' do
        get '/transaction.xml'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok
<commit_msg>Update server spec to reflect new route behavior<commit_after>require 'spec_helper'
describe CSV2API::Server do
  include Rack::Test::Methods

  def app
    CSV2API::Server
  end

  describe '/tasks' do
    context 'when called with .json extension' do
      it 'returns tasks.csv in json' do
        get '/tasks.json'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = json(last_response.body).first
        expect(parsed_response).to be_a(Hash)
      end
    end

    context 'when called with .xml extension' do
      it 'returns tasks.csv in XML' do
        get '/tasks.xml'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = xml(last_response.body)
        expect(parsed_response).to be_a(Hash)
      end
    end
  end

  describe '/transaction' do
    context 'when called with .json extension' do
      it 'returns transaction.csv in json' do
        get '/transaction.json'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

        parsed_response = json(last_response.body).first
        expect(parsed_response).to be_a(Hash)
      end
    end

    context 'when called with .xml extension' do
      it 'returns transaction.csv in XML' do
        get '/transaction.xml'
        expect(last_response.body).not_to be_empty
        expect(last_response).to be_ok

{'fraction_non_alphanumeric': 0.08092892329345532, 'fraction_numerical': 0.0014074595355383533, 'mean_word_length': 2.6078680203045685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5420485', 'n_tokens_mistral': 846, 'n_tokens_neox': 837, 'n_words': 231}