<commit_before>require "#{File.dirname(__FILE__)}/../lib/rack/promises"
require "#{File.dirname(__FILE__)}/../lib/rack/promises/no_promise_call_error"

describe Rack::Promises do
  before(:each) do
    Object.send(:remove_const, :SomeRackClass) if Object.constants.include?(:SomeRackClass)
    class SomeRackClass
      include Rack::Promises
    end
  end

  it "should respond to call" do
    instance = SomeRackClass.new
    instance.should respond_to(:call)
  end

  it "should raise an exception if call is called and pcall is not defined" do
    instance = SomeRackClass.new
    -> {
      instance.call({})
    }.should raise_error NoPromiseCallError
  end
end<commit_msg>spec wrt making sure the class returns a normal value if one comes back<commit_after>require "em-promise"
require "#{File.dirname(__FILE__)}/../lib/rack/promises"
require "#{File.dirname(__FILE__)}/../lib/rack/promises/no_promise_call_error"

describe Rack::Promises do
  before(:each) do
    Object.send(:remove_const, :SomeRackClass) if Object.constants.include?(:SomeRackClass)
    class SomeRackClass
      include Rack::Promises
    end
  end

  it "should respond to call" do
    instance = SomeRackClass.new
    instance.should respond_to(:call)
  end

  it "should raise an exception if call is called and pcall is not defined" do
    instance = SomeRackClass.new
    -> {
      instance.call({})
    }.should raise_error NoPromiseCallError
  end

  it "should return watever value it's given if the result is not a promise" do
    SomeRackClass.send(:define_method, :pcall) do |env|
      [200, {}, "Hello world"]
    end
    instance = SomeRackClass.new
    instance.call({}).should == [200, {}, "Hello world"]
  end
end
{'fraction_non_alphanumeric': 0.1088355763604447, 'fraction_numerical': 0.003510825043885313, 'mean_word_length': 3.75, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '763839', 'n_tokens_mistral': 552, 'n_tokens_neox': 534, 'n_words': 150}