<commit_before>
shared_examples "a poll class" do
  
  subject { poll_class.new pull }
  
  let(:push) { ZMQ::Socket.new(ZMQ::PUSH).tap { |s| s.bind    'inproc://p1' } }
  let(:pull) { ZMQ::Socket.new(ZMQ::PULL).tap { |s| s.connect 'inproc://p1' } }
  let(:push2){ ZMQ::Socket.new(ZMQ::PUSH).tap { |s| s.bind    'inproc://p2' } }
  let(:pull2){ ZMQ::Socket.new(ZMQ::PULL).tap { |s| s.connect 'inproc://p2' } }
  
  before {
    push
    pull
    push2
    pull2
  }
  
  after {
    push.close
    pull.close
    push2.close
    pull2.close
  }
  
  around { |test| Timeout.timeout(1) { test.run } }
  
  context "initializer socket args:" do
    it "can accept a single socket with no event flags" do
      push.send_string 'test'
      
      poll_class.new(pull).tap { |p|
        value = {pull => ZMQ::POLLIN}
        p.run.should eq value
      }
    end
    
    it "can accept multiple sockets with no event flags" do
      push.send_string 'test'
      push2.send_string 'test'
      
      poll_class.new(pull, pull2).tap { |p|
        p.run.count.should eq 2
      }
    end
    
    it "can accept a single socket with an event flag" do
      poll_class.new(push => ZMQ::POLLOUT).tap { |p|
        value = {push => ZMQ::POLLOUT}
        p.run.should eq value
      }
    end
    
    it "can accept multiple sockets with event flags" do
      poll_class.new(push => ZMQ::POLLOUT, push2 => ZMQ::POLLOUT)<commit_msg>Stub DefaultContext in poll_shared tests for isolation<commit_after>
shared_examples "a poll class" do
  
  subject { poll_class.new pull }
  
  before { stub_const "ZMQ::DefaultContext", ZMQ::Context.new }
  
  let(:push)  { ZMQ::Socket.new(ZMQ::PUSH).tap { |s| s.bind    'inproc://p1' } }
  let(:pull)  { ZMQ::Socket.new(ZMQ::PULL).tap { |s| s.connect 'inproc://p1' } }
  let(:push2) { ZMQ::Socket.new(ZMQ::PUSH).tap { |s| s.bind    'inproc://p2' } }
  let(:pull2) { ZMQ::Socket.new(ZMQ::PULL).tap { |s| s.connect 'inproc://p2' } }
  
  before { push; pull; push2; pull2 }
  
  around { |test| Timeout.timeout(1) { test.run } }
  
  
  context "initializer socket args:" do
    it "can accept a single socket with no event flags" do
      push.send_string 'test'
      
      poll_class.new(pull).tap { |p|
        value = {pull => ZMQ::POLLIN}
        p.run.should eq value
      }
    end
    
    it "can accept multiple sockets with no event flags" do
      push.send_string 'test'
      push2.send_string 'test'
      
      poll_class.new(pull, pull2).tap { |p|
        p.run.count.should eq 2
      }
    end
    
    it "can accept a single socket with an event flag" do
      poll_class.new(push => ZMQ::POLLOUT).tap { |p|
        value = {push => ZMQ::POLLOUT}
        p.run.should eq value
      }
    end
    
    it "can accept multiple sockets with event flags" do
      poll_class.new(push => ZMQ::POLLOUT, push2 => ZMQ::POLLOUT)
{'fraction_non_alphanumeric': 0.1417624521072797, 'fraction_numerical': 0.009752699407871821, 'mean_word_length': 2.3629976580796255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1635983', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1052, 'n_words': 254}