<commit_before>require File.dirname(__FILE__) + '/spec_helper'

describe YARD::Verifier do
  describe '#parse_expressions' do
    it "should create #__execute method" do
      v = Verifier.new("expr1")
      v.should respond_to(:__execute)
    end

    it "should parse @tagname into tag('tagname')" do
      obj = mock(:object)
      obj.should_receive(:tag).with('return')
      Verifier.new('@return').call(obj)
    end

    it "should parse @@tagname into object.tags('tagname')" do
      obj = mock(:object)
      obj.should_receive(:tags).with('return')
      Verifier.new('@@return').call(obj)
    end

    it "should send any missing methods to object" do
      obj = mock(:object)
      obj.should_receive(:has_tag?).with('return')
      Verifier.new('has_tag?("return")').call(obj)
    end

    it "should allow multiple expressions" do
      obj = mock(:object)
      obj.should_receive(:tag).with('return').and_return(true)
      obj.should_receive(:tag).with('param').and_return(false)
      Verifier.new('@return', '@param').call(obj).should == false
    end
  end
  
  describe '#o' do
    it "should alias object to o" do
      obj = mock(:object)
      obj.should_receive(:a).ordered
      Verifier.new('o.a').call(obj)
    end
  end

  describe '#call' do
    it "should mock a nonexistent tag so that exceptions are not raised" do
      obj = mock(:object)
      obj.should_receive(:tag).and_return(nil)
      Verifier.new('@return.text').call(obj).should == false
    end
  end
  
  describe '#expressions' do
    it "should maintain a list of all unparsed expressions" do
      Verifier.new('@return.text', '@private').expressions.should == ['@return.text', '@private']
    end<commit_msg>Add spec for Verifier<commit_after>require File.dirname(__FILE__) + '/spec_helper'

describe YARD::Verifier do
  describe '#parse_expressions' do
    it "should create #__execute method" do
      v = Verifier.new("expr1")
      v.should respond_to(:__execute)
    end

    it "should parse @tagname into tag('tagname')" do
      obj = mock(:object)
      obj.should_receive(:tag).with('return')
      Verifier.new('@return').call(obj)
    end

    it "should parse @@tagname into object.tags('tagname')" do
      obj = mock(:object)
      obj.should_receive(:tags).with('return')
      Verifier.new('@@return').call(obj)
    end

    it "should send any missing methods to object" do
      obj = mock(:object)
      obj.should_receive(:has_tag?).with('return')
      Verifier.new('has_tag?("return")').call(obj)
    end

    it "should allow multiple expressions" do
      obj = mock(:object)
      obj.should_receive(:tag).with('return').and_return(true)
      obj.should_receive(:tag).with('param').and_return(false)
      Verifier.new('@return', '@param').call(obj).should == false
    end
  end
  
  describe '#o' do
    it "should alias object to o" do
      obj = mock(:object)
      obj.should_receive(:a).ordered
      Verifier.new('o.a').call(obj)
    end
  end

  describe '#call' do
    it "should mock a nonexistent tag so that exceptions are not raised" do
      obj = mock(:object)
      obj.should_receive(:tag).and_return(nil)
      Verifier.new('@return.text').call(obj).should == false
    end
    
    it "should not fail if no expressions were added" do
      lambda { Verifier.new.call(nil) }.should_not raise_error
    end
  end
  
  describe '#expressions' do
    it "should maintain a list of all unparsed expressions" do
      Verifier.new('@return.text', '@private').expressions.should == ['@return.text', '@private']
    end
{'fraction_non_alphanumeric': 0.14069081718618365, 'fraction_numerical': 0.0005616399887672002, 'mean_word_length': 3.1905882352941175, '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': '3268197', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1108, 'n_words': 277}