<commit_before>require 'spec_helper'

describe 'basic rails4 test' do

  # Rails 4 is 1.9+
  if RUBY_VERSION >= '1.9'
    mutable_app 'rails4/basic'
    deploy <<-END.gsub(/^ {6}/,'')
      ---
      application:
        RAILS_ROOT: #{File.dirname(__FILE__)}/../target/apps/rails4/basic
        RAILS_ENV: development
      web:
        context: /basic-rails4
      ruby:
        version: #{RUBY_VERSION[0,3]}
    END

    it 'should do a basic get' do
      visit '/basic-rails4'
      page.should have_content('It works')
      page.find('#success')[:class].should == 'basic-rails4'
    end

    context 'streaming' do
      it "should work for small responses" do
        verify_streaming("/basic-rails4/root/streaming?count=0")
      end

      it "should work for large responses" do
        verify_streaming("/basic-rails4/root/streaming?count=500")
      end

      def verify_streaming(url)
        uri = URI.parse(page.driver.send(:url, url))
        Net::HTTP.get_response(uri) do |response|
          response.should be_chunked
          response.header['transfer-encoding'].should == 'chunked'
          chunk_count, body = 0, ""
          response.read_body do |chunk|
            chunk_count += 1
            body += chunk
          end
          body.should include('It works')
          body.each_line do |line|
            line.should_not match(/^\d+\s*$/)
          end
          chunk_count.should be > 1<commit_msg>Pend these Rails 4 streaming integs until JRuby 1.7.6 comes out<commit_after>require 'spec_helper'

describe 'basic rails4 test' do

  # Rails 4 is 1.9+
  if RUBY_VERSION >= '1.9'
    mutable_app 'rails4/basic'
    deploy <<-END.gsub(/^ {6}/,'')
      ---
      application:
        RAILS_ROOT: #{File.dirname(__FILE__)}/../target/apps/rails4/basic
        RAILS_ENV: development
      web:
        context: /basic-rails4
      ruby:
        version: #{RUBY_VERSION[0,3]}
    END

    it 'should do a basic get' do
      visit '/basic-rails4'
      page.should have_content('It works')
      page.find('#success')[:class].should == 'basic-rails4'
    end

    context 'streaming' do
      pending 'jruby 1.7.6 fiber fixes' do
        it "should work for small responses" do
          verify_streaming("/basic-rails4/root/streaming?count=0")
        end

        it "should work for large responses" do
          verify_streaming("/basic-rails4/root/streaming?count=500")
        end
      end

      def verify_streaming(url)
        uri = URI.parse(page.driver.send(:url, url))
        Net::HTTP.get_response(uri) do |response|
          response.should be_chunked
          response.header['transfer-encoding'].should == 'chunked'
          chunk_count, body = 0, ""
          response.read_body do |chunk|
            chunk_count += 1
            body += chunk
          end
          body.should include('It works')
          body.each_line do |line|
            line.should_not match(/^\d+\s*$/)
          end
          chunk_count.should be > 1
{'fraction_non_alphanumeric': 0.12194304857621441, 'fraction_numerical': 0.017755443886097153, 'mean_word_length': 2.0975103734439835, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6191336', 'n_tokens_mistral': 972, 'n_tokens_neox': 913, 'n_words': 220}