<commit_before>require 'spec_helper'

describe Travis::Github::Config do
  include Travis::Testing::Stubs

  let(:url)      { 'https://raw.github.com/svenfuchs/minimal/62aae5f70ceee39123ef/.travis.yml' }
  let(:subject)  { Travis::Github::Config.new(url) }
  let(:response) { stub('response', :success? => true, :body => 'foo: Foo') }
  let(:http)     { stub('http', :get => response) }
  let(:result)   { subject.fetch }

  before :each do
    subject.stubs(:http).returns(http)
  end

  describe 'config' do
    it 'returns a hash' do
      result.should be_a(Hash)
    end

    it 'yaml parses the response body if the response is successful' do
      result['foo'].should == 'Foo'
    end

    it "merges { '.result' => 'configured' } to the actual configuration" do
      result['.result'].should == 'configured'
    end

    it "returns { '.result' => 'not_found' } if the repository has not .travis.yml" do
      response.expects(:success?).returns(false)
      response.expects(:status).returns(404)
      result['.result'].should == 'not_found'
    end

    it "returns { '.result' => 'server_error' } if a 500 server error is returned" do
      response.expects(:success?).returns(false)
      response.expects(:status).returns(500)
      result['.result'].should == 'server_error'
    end
  end

  describe 'invalid yml' do
    let(:response) { stub('response', :success? => true, :body => "\tfoo: Foo") }

    it "returns { '.result' => 'parsing_error' } if the .travis.yml is invalid" do
      result['.result'].should == 'parsing_failed'
    end
  end

  describe 'http_options' do
    before :each do
      @ssl = Travis.config.ssl
    end

    after :each do
      Travis.config.ssl = @ssl
    end

    it 'returns a hash containing a :ca_path value if present' do
      Travis.config.ssl = { :ca_path => '/path/to/certs' }
      subject.send(:http_options)[:ssl][:ca_path].should == '/path/to/certs'
    end

    it 'returns a hash containing a :ca_file value if present' do
      Travis.config.ssl = { :ca_file => '/path/to/cert.file' }
      subject.send(:http_options)[:ssl][:ca_file].should == '/path/to/cert.file'
    end
  end
end
<commit_msg>move the invalid yml test inside of the config describe block<commit_after>require 'spec_helper'

describe Travis::Github::Config do
  include Travis::Testing::Stubs

  let(:url)      { 'https://raw.github.com/svenfuchs/minimal/62aae5f70ceee39123ef/.travis.yml' }
  let(:subject)  { Travis::Github::Config.new(url) }
  let(:response) { stub('response', :success? => true, :body => 'foo: Foo') }
  let(:http)     { stub('http', :get => response) }
  let(:result)   { subject.fetch }

  before :each do
    subject.stubs(:http).returns(http)
  end

  describe 'config' do
    it 'returns a hash' do
      result.should be_a(Hash)
    end

    it 'yaml parses the response body if the response is successful' do
      result['foo'].should == 'Foo'
    end

    it "merges { '.result' => 'configured' } to the actual configuration" do
      result['.result'].should == 'configured'
    end

    it "returns { '.result' => 'not_found' } if the repository has not .travis.yml" do
      response.expects(:success?).returns(false)
      response.expects(:status).returns(404)
      result['.result'].should == 'not_found'
    end

    it "returns { '.result' => 'server_error' } if a 500 server error is returned" do
      response.expects(:success?).returns(false)
      response.expects(:status).returns(500)
      result['.result'].should == 'server_error'
    end

    describe 'invalid yml' do
      let(:response) { stub('response', :success? => true, :body => "\tfoo: Foo") }

      it "returns { '.result' => 'parsing_error' } if the .travis.yml is invalid" do
        result['.result'].should == 'parsing_failed'
      end
    end
  end

  describe 'http_options' do
    before :each do
      @ssl = Travis.config.ssl
    end

    after :each do
      Travis.config.ssl = @ssl
    end

    it 'returns a hash containing a :ca_path value if present' do
      Travis.config.ssl = { :ca_path => '/path/to/certs' }
      subject.send(:http_options)[:ssl][:ca_path].should == '/path/to/certs'
    end

    it 'returns a hash containing a :ca_file value if present' do
      Travis.config.ssl = { :ca_file => '/path/to/cert.file' }
      subject.send(:http_options)[:ssl][:ca_file].should == '/path/to/cert.file'
    end
  end
end

{'fraction_non_alphanumeric': 0.15163934426229508, 'fraction_numerical': 0.008652094717668488, 'mean_word_length': 3.071362372567192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '5755323', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1425, 'n_words': 364}