<commit_before>#!/usr/bin/env bundle exec rspec
# encoding: utf-8

require "spec_helper"

require "sockjs"
require "sockjs/session"
require "sockjs/transports/xhr"

class Session < SockJS::Session
  include ResetSessionMixin

  def set_status_for_tests(status)
    @buffer = SockJS::Buffer.new(status)
    @status = status
    self
  end
end

describe Session do
  subject do
    connection = SockJS::Connection.new {}
    transport  = SockJS::Transports::XHRPost.new(connection, Hash.new)

    def transport.session_finish
    end

    described_class.new(transport, open: Array.new)
  end

  describe "#initialize(transport, callback)"

  describe "#send(data, *args)"

  describe "#finish" do
    it "should raise an error if there's no response assigned"
  end

  describe "#receive_message"

  describe "#process_messages" # ?

  describe "#process_buffer" # ?

  describe "#create_response" # ?

  describe "#check_status" do
    before(:each) do
      @subject = subject.set_status_for_tests(:opening)

      def @subject.callback_run
        @callback_run
      end

      def @subject.callback_run=(status)
        @callback_run = status
      end

      @subject.callbacks[:open] << Proc.new do |session|
        session.callback_run = true
      end
    end

    it "should execute the open callback" do
      @subject.check_status
      @subject.callback_run.should be_true
    end

    it "should change status fro opening to open" do
      @subject.check_status
      @subject.should be_open
    end<commit_msg>What are we going to spec on Session#create_response.<commit_after>#!/usr/bin/env bundle exec rspec
# encoding: utf-8

require "spec_helper"

require "sockjs"
require "sockjs/session"
require "sockjs/transports/xhr"

class Session < SockJS::Session
  include ResetSessionMixin

  def set_status_for_tests(status)
    @buffer = SockJS::Buffer.new(status)
    @status = status
    self
  end
end

describe Session do
  subject do
    connection = SockJS::Connection.new {}
    transport  = SockJS::Transports::XHRPost.new(connection, Hash.new)

    def transport.session_finish
    end

    described_class.new(transport, open: Array.new)
  end

  describe "#initialize(transport, callback)"

  describe "#send(data, *args)"

  describe "#finish" do
    it "should raise an error if there's no response assigned"
  end

  describe "#receive_message"

  describe "#process_messages" # ?

  describe "#process_buffer" # ?

  describe "#create_response(&block)" do
    it "should execute the block"
    it "should clear received messages"
    it "should return a frame"
  end

  describe "#check_status" do
    before(:each) do
      @subject = subject.set_status_for_tests(:opening)

      def @subject.callback_run
        @callback_run
      end

      def @subject.callback_run=(status)
        @callback_run = status
      end

      @subject.callbacks[:open] << Proc.new do |session|
        session.callback_run = true
      end
    end

    it "should execute the open callback" do
      @subject.check_status
      @subject.callback_run.should be_true
    end

    it "should change status fro opening to open" do
      @subject.check_status
      @subject.should be_open
    end
{'fraction_non_alphanumeric': 0.09195760598503741, 'fraction_numerical': 0.0006234413965087282, 'mean_word_length': 3.2223684210526318, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1753364', 'n_tokens_mistral': 995, 'n_tokens_neox': 950, 'n_words': 265}