<commit_before>require 'spec_helper'

describe Oga::XPath::Evaluator do
  context 'following axis' do
    before do
      # Strip whitespace so it's easier to retrieve/compare elements.
      @document = parse(<<-EOF.strip.gsub(/\s+/m, ''))
<root>
  <foo>
    <bar></bar>
    <baz>
      <baz></baz>
    </baz>
  </foo>
  <baz></baz>
</root>
      EOF

      @first_baz  = @document.children[0].children[1]
      @second_baz = @first_baz.children[0]
      @third_baz  = @document.children[0].children[0].children[1]
      @evaluator  = described_class.new(@document)
    end

    # This should return an empty set since the document doesn't have any
    # following nodes.
    context 'using a document as the root' do
      before do
        @set = @evaluator.evaluate('following::foo')
      end

      it_behaves_like :empty_node_set
    end

    context 'matching nodes in the current context' do
      before do
        @set = @evaluator.evaluate('root/foo/following::baz')
      end

      it_behaves_like :node_set, :length => 1

      example 'return the second <baz> node' do
        @set[0].should == @first_baz
      end
    end
<commit_msg>Corrected the XPath "following" axis specs.<commit_after>require 'spec_helper'

describe Oga::XPath::Evaluator do
  context 'following axis' do
    before do
      # Strip whitespace so it's easier to retrieve/compare elements.
      @document = parse(<<-EOF.strip.gsub(/\s+/m, ''))
<root>
  <foo>
    <bar></bar>
    <baz>
      <baz></baz>
    </baz>
  </foo>
  <baz></baz>
</root>
      EOF

      @first_baz  = @document.children[0].children[0].children[1]
      @second_baz = @first_baz.children[0]
      @third_baz  = @document.children[0].children[1]
      @evaluator  = described_class.new(@document)
    end

    # This should return an empty set since the document doesn't have any
    # following nodes.
    context 'using a document as the root' do
      before do
        @set = @evaluator.evaluate('following::foo')
      end

      it_behaves_like :empty_node_set
    end

    context 'matching nodes in the current context' do
      before do
        @set = @evaluator.evaluate('root/foo/following::baz')
      end

      it_behaves_like :node_set, :length => 1

      example 'return the third <baz> node' do
        @set[0].should == @third_baz
      end
    end

{'fraction_non_alphanumeric': 0.12387483926275182, 'fraction_numerical': 0.006858122588941277, 'mean_word_length': 2.60741885625966, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, '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': '5209339', 'n_tokens_mistral': 815, 'n_tokens_neox': 749, 'n_words': 201}