<commit_before>shared_examples_for 'client' do
  describe :mkdir_p do
    before(:each) do
      @path_ary = %w[test mkdir_p path creation]
      @bogus_path = File.join('/', *@path_ary)
      @zk.rm_rf('/test')
    end
    
    it %[should create all intermediate paths for the path givem] do
      @zk.rm_rf('/test')
      @zk.should_not be_exists(@bogus_path)
      @zk.should_not be_exists(File.dirname(@bogus_path))
      @zk.mkdir_p(@bogus_path)
      @zk.should be_exists(@bogus_path)
    end
  end

  # nail down all possible cases
  describe :create do
    describe 'only path given' do
      it %[should create a node with blank data] do
        @zk.create(@base_path)
        @zk.get(@base_path).first.should == ''
      end
    end

    describe 'path and data given' do
      it %[should create a node with the path and data] do
        @zk.create(@base_path, 'blah')
        @zk.get(@base_path).first.should == 'blah'
      end
    end

    describe 'path and sequential' do
      it %[should create a sequential node with blank data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", :sequential => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        @zk.get(path).first.should == ''
      end

      it %[should create a sequential node with given data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", 'thedata', :sequential => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == 'thedata'
        st.should_not be_ephemeral
      end
    end

    describe 'path and ephemeral' do
      it %[should create an ephemeral node with blank data] do
        @zk.create(@base_path, :ephemeral => true)
        @zk.get(@base_path).last.should be_ephemeral
      end

      it %[should create an ephemeral node with given data] do
        @zk.create(@base_path, 'thedata', :ephemeral => true)
        data, stat = @zk.get(@base_path)
        data.should == 'thedata'
        stat.should be_ephemeral
      end
    end

    describe 'path and sequential and ephemeral' do
      it %[should create a sequential ephemeral node with blank data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", :sequential => true, :ephemeral => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == ''
        st.should be_ephemeral
      end

      it %[should create a sequential ephemeral node with given data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", 'thedata', :sequential => true, :ephemeral => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == 'thedata'
        st.should be_ephemeral
      end

    end
  end

  describe :stat do
    describe 'for a missing node' do
      before do
        @missing_path = '/thispathdoesnotexist'
        @zk.delete(@missing_path) rescue ZK::Exceptions::NoNode
      end

      it %[should not raise any error] do
        lambda { @zk.stat(@missing_path) }.should_not raise_error<commit_msg>check to make sure we only accept 2 params for create<commit_after>shared_examples_for 'client' do
  describe :mkdir_p do
    before(:each) do
      @path_ary = %w[test mkdir_p path creation]
      @bogus_path = File.join('/', *@path_ary)
      @zk.rm_rf('/test')
    end
    
    it %[should create all intermediate paths for the path givem] do
      @zk.rm_rf('/test')
      @zk.should_not be_exists(@bogus_path)
      @zk.should_not be_exists(File.dirname(@bogus_path))
      @zk.mkdir_p(@bogus_path)
      @zk.should be_exists(@bogus_path)
    end
  end

  # nail down all possible cases
  describe :create do
    describe 'only path given' do
      it %[should create a node with blank data] do
        @zk.create(@base_path)
        @zk.get(@base_path).first.should == ''
      end
    end

    describe 'path and data given' do
      it %[should create a node with the path and data] do
        @zk.create(@base_path, 'blah')
        @zk.get(@base_path).first.should == 'blah'
      end
    end

    describe 'path and sequential' do
      it %[should create a sequential node with blank data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", :sequential => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        @zk.get(path).first.should == ''
      end

      it %[should create a sequential node with given data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", 'thedata', :sequential => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == 'thedata'
        st.should_not be_ephemeral
      end
    end

    describe 'path and ephemeral' do
      it %[should create an ephemeral node with blank data] do
        @zk.create(@base_path, :ephemeral => true)
        @zk.get(@base_path).last.should be_ephemeral
      end

      it %[should create an ephemeral node with given data] do
        @zk.create(@base_path, 'thedata', :ephemeral => true)
        data, stat = @zk.get(@base_path)
        data.should == 'thedata'
        stat.should be_ephemeral
      end
    end

    describe 'path and sequential and ephemeral' do
      it %[should create a sequential ephemeral node with blank data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", :sequential => true, :ephemeral => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == ''
        st.should be_ephemeral
      end

      it %[should create a sequential ephemeral node with given data] do
        @zk.create(@base_path)
        path = @zk.create("#{@base_path}/v", 'thedata', :sequential => true, :ephemeral => true)
        path.start_with?(@base_path).should be_true

        File.basename(path).should match(/v\d+/)

        data, st = @zk.get(path)
        data.should == 'thedata'
        st.should be_ephemeral
      end
    end

    it %[should barf if someone hands 3 params] do
      lambda { @zk.create(@base_path, 'data', :sequence) }.should raise_error(ArgumentError)
    end
  end

  describe :stat do
    describe 'for a missing node' do
      before do
        @missing_path = '/thispathdoesnotexist'
        @zk.delete(@missing_path) rescue ZK::Exceptions::NoNode
      end

      it %[should not raise any error] do
        lambda { @zk.stat(@missing_path) }.should_not raise_error
{'fraction_non_alphanumeric': 0.12238979118329467, 'fraction_numerical': 0.0002900232018561485, 'mean_word_length': 2.48685540950455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '5300345', 'n_tokens_mistral': 2318, 'n_tokens_neox': 2229, 'n_words': 593}