<commit_before>require 'spec_helper'

describe 'Parameter Types' do
  describe 'String' do
    it 'coerces strings' do
      get('/coerce/string', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq('1234')
      end
    end
  end

  describe 'Integer' do
    it 'coerces integers' do
      get('/coerce/integer', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq(1234)
      end
    end

    it 'returns 400 on requests when integer is invalid' do
      get('/coerce/integer', arg: '123abc') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'123abc' is not a valid Integer")
      end
    end
  end

  describe 'Float' do
    it 'coerces floats' do
      get('/coerce/float', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq(1234.0)
      end
    end

    it 'returns 400 on requests when float is invalid' do
      get('/coerce/float', arg: '123abc') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'123abc' is not a valid Float")
      end
    end
  end

  describe 'Time' do
    it 'coerces time' do
      get('/coerce/time', arg: '20130117') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to match(/2013-01-17 00:00:00/)
      end
    end

    it 'returns 400 on requests when time is invalid' do
      get('/coerce/time', arg: '123abc') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'123abc' is not a valid Time")
      end
    end
  end

  describe 'Date' do
    it 'coerces date' do
      get('/coerce/date', arg: '20130117') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq('2013-01-17')
      end
    end<commit_msg>Fix failing test for time parameter coercion<commit_after>require 'spec_helper'

describe 'Parameter Types' do
  describe 'String' do
    it 'coerces strings' do
      get('/coerce/string', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq('1234')
      end
    end
  end

  describe 'Integer' do
    it 'coerces integers' do
      get('/coerce/integer', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq(1234)
      end
    end

    it 'returns 400 on requests when integer is invalid' do
      get('/coerce/integer', arg: '123abc') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'123abc' is not a valid Integer")
      end
    end
  end

  describe 'Float' do
    it 'coerces floats' do
      get('/coerce/float', arg: '1234') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq(1234.0)
      end
    end

    it 'returns 400 on requests when float is invalid' do
      get('/coerce/float', arg: '123abc') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'123abc' is not a valid Float")
      end
    end
  end

  describe 'Time' do
    it 'coerces time' do
      get('/coerce/time', arg: '20130117') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to match(/2013-01-17 00:00:00/)
      end
    end

    it 'returns 400 on requests when time is invalid' do
      get('/coerce/time', arg: 'noon') do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to eq("'noon' is not a valid Time")
      end
    end
  end

  describe 'Date' do
    it 'coerces date' do
      get('/coerce/date', arg: '20130117') do |response|
        expect(response.status).to eql 200
        expect(JSON.parse(response.body)['arg']).to eq('2013-01-17')
      end
    end
{'fraction_non_alphanumeric': 0.13852400286601385, 'fraction_numerical': 0.0530212562694053, 'mean_word_length': 2.6963812886142984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6629409', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1330, 'n_words': 379}