<commit_before># To change this template, choose Tools | Templates
# and open the template in the editor.

require 'command_dispatch'

describe CommandDispatch do
  before(:each) do
    @command_dispatch = CommandDispatch.new
    @command = Proc.new { |args| args.join(',') }
    @env = { 'QUERY_STRING' => 'test+one+two+three+1%202%2B3' }
  end

  it "contains a map of commands" do
    @command_dispatch['test'] = @command
    @command_dispatch['test'].should == @command
    @command_dispatch['anything else'].should be_nil
  end

  it "rejects actions that cannot be invoked" do
    action = "String has no call() method"
    expect { @command_dispatch['test'] = action }.to raise_error
  end

  it "should wrap the output of the action in a rackable http response" do
    @command_dispatch['test']= @command
    response = @command_dispatch.call @env
    response[0].should be >= 200
    response[0].should be < 300
    response[1].should be_an_instance_of Hash
    response[2].should be == "test,one,two,three,1 2+3"
  end

  it "should provide the Content-Length header" do<commit_msg>An extra test for command dispatch.<commit_after># To change this template, choose Tools | Templates
# and open the template in the editor.

require 'command_dispatch'

describe CommandDispatch do
  before(:each) do
    @command_dispatch = CommandDispatch.new
    @command = Proc.new { |args| args.join(',') }
    @env = { 'QUERY_STRING' => 'test+one+two+three+1%202%2B3' }
  end

  it "contains a map of commands" do
    @command_dispatch['test'] = @command
    @command_dispatch['test'].should == @command
    @command_dispatch['anything else'].should be_nil
  end

  it "rejects actions that cannot be invoked" do
    action = "String has no call() method"
    expect { @command_dispatch['test'] = action }.to raise_error
  end

  it "should pass an args array to the dispatched action" do
    @command_dispatch['test'] = Proc.new do |args|
      args.should be_an_instance_of Array
    end
  end

  it "should wrap the output of the action in a rackable http response" do
    @command_dispatch['test']= @command
    response = @command_dispatch.call @env
    response[0].should be >= 200
    response[0].should be < 300
    response[1].should be_an_instance_of Hash
    response[2].should be == "test,one,two,three,1 2+3"
  end

  it "should provide the Content-Length header" do
{'fraction_non_alphanumeric': 0.11073684210526316, 'fraction_numerical': 0.016, 'mean_word_length': 3.8989690721649484, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3719160', 'n_tokens_mistral': 755, 'n_tokens_neox': 718, 'n_words': 240}