<commit_before>require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe 'SecureEscrow::Middleware' do
  let(:app) { MockEngine.new }
  let(:store) { MockRedis.new }
  let(:middleware) { SecureEscrow::Middleware.new app, store }
  let(:env_keep) { {} }
  let(:env_serve) { {} }
  let(:env_pass) { {} }

  it 'should be callable' do
    middleware.should respond_to(:call).with(1).argument
  end

  it 'should check whether to keep a request in escrow' do
    middleware.should_receive(:serve_from_escrow?).with(env_pass)
    middleware.call env_pass
  end
end
<commit_msg>Test pass-through to Rails application<commit_after>require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe 'SecureEscrow::Middleware' do
  let(:app) { MockEngine.new }
  let(:store) { MockRedis.new }
  let(:middleware) { SecureEscrow::Middleware.new app, store }
  let(:env_keep) { {} }
  let(:env_serve) { {} }
  let(:env_pass) { {} }

  it 'should be callable' do
    middleware.should respond_to(:call).with(1).argument
  end

  it 'should check whether to keep a request in escrow' do
    middleware.should_receive(:serve_from_escrow?).with(env_pass)
    middleware.call env_pass
  end

  context 'when request is not served from escrow' do
    it 'should check whether to serve a request from escrow' do
      middleware.should_receive(:keep_in_escrow?).with(env_pass)
      middleware.call env_pass
    end

    context 'when request does not interact with escrow' do
      it 'should return response from app' do
        middleware.call(env_pass).should == app.call(env_pass)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11646341463414635, 'fraction_numerical': 0.0012195121951219512, 'mean_word_length': 4.160377358490566, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7356150', 'n_tokens_mistral': 553, 'n_tokens_neox': 535, 'n_words': 131}