<commit_before>require 'spec_helper'

SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'

describe 'Tag, Unit' do

  let(:clazz) { CukeModeler::Tag }
  let(:element) { clazz.new }


  describe 'common behavior' do

    it_should_behave_like 'a modeled element'
    it_should_behave_like 'a sourced element'
    it_should_behave_like 'a raw element'

  end


  describe 'unique behavior' do

    it 'can be parsed from stand alone text' do
      source = '@a_tag'

      expect { @element = clazz.new(source) }.to_not raise_error
      @element.name.should == '@a_tag'
    end

    it 'provides a descriptive filename when being parsed from stand alone text' do
      source = 'bad tag text'

      expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_tag\.feature'/)
    end

    it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array([:type, :location, :name])
      expect(raw_data[:type]).to eq(:Tag)
    end

    it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array([:type, :location, :name])
      expect(raw_data[:type]).to eq('Tag')
    end

    it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array(['name', 'line'])
      expect(raw_data['name']).to eq('@a_tag')
    end

    it 'has a name' do
      element.should respond_to(:name)
    end

    it 'can get and set its name' do
      expect(element).to respond_to(:name=)

      element.name = :some_name
      element.name.should == :some_name
      element.name = :some_other_name
      element.name.should == :some_other_name
    end

    describe 'tag output edge cases' do

      it 'is a String' do
        element.to_s.should be_a(String)
      end


      context 'a new tag object' do

        let(:tag) { clazz.new }


        it 'can output an empty tag' do
          expect { tag.to_s }.to_not raise_error
        end

      end

    end

  end

end<commit_msg>Adding missing tests.<commit_after>require 'spec_helper'

SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'

describe 'Tag, Unit' do

  let(:clazz) { CukeModeler::Tag }
  let(:element) { clazz.new }


  describe 'common behavior' do

    it_should_behave_like 'a modeled element'
    it_should_behave_like 'a sourced element'
    it_should_behave_like 'a raw element'

  end


  describe 'unique behavior' do

    it 'can be parsed from stand alone text' do
      source = '@a_tag'

      expect { @element = clazz.new(source) }.to_not raise_error
      @element.name.should == '@a_tag'
    end

    it 'provides a descriptive filename when being parsed from stand alone text' do
      source = 'bad tag text'

      expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_tag\.feature'/)
    end

    it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array([:type, :location, :name])
      expect(raw_data[:type]).to eq(:Tag)
    end

    it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array([:type, :location, :name])
      expect(raw_data[:type]).to eq('Tag')
    end

    it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
      tag = clazz.new('@a_tag')
      raw_data = tag.raw_element

      expect(raw_data.keys).to match_array(['name', 'line'])
      expect(raw_data['name']).to eq('@a_tag')
    end

    it 'has a name' do
      element.should respond_to(:name)
    end

    it 'can get and set its name' do
      expect(element).to respond_to(:name=)

      element.name = :some_name
      element.name.should == :some_name
      element.name = :some_other_name
      element.name.should == :some_other_name
    end


    describe 'abstract instantiation' do

      let(:tag) { clazz.new }


      it 'starts with no name' do
        expect(tag.name).to be_nil
      end

    end


    describe 'tag output edge cases' do

      it 'is a String' do
        element.to_s.should be_a(String)
      end


      context 'a new tag object' do

        let(:tag) { clazz.new }


        it 'can output an empty tag' do
          expect { tag.to_s }.to_not raise_error
        end

      end

    end

  end

end
{'fraction_non_alphanumeric': 0.1089567966280295, 'fraction_numerical': 0.0025289778714436247, 'mean_word_length': 2.7136150234741785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7558562', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1532, 'n_words': 441}