<commit_before><commit_msg>Added unit test for maybe_alias<commit_after>require 'spec_helper'

class Foo
  include XML::Mapping

  def foo
    'foo'
  end

  @@result = maybe_alias :bar, :foo

  def self.result
    @@result
  end
end

module XML
  module Mapping
    module ClassMethods
      describe "#maybe_alias" do
        it 'aliases a method' do
          expect(Foo.result).to be(Foo)
          expect(Foo.new.bar).to eq('foo')
        end

        # we can't directly test that we're not double-aliasing,
        # but simplecov verifies that we're hitting the 'self' return
        # on the second invocation
        it "doesn't double-alias" do
          result = Foo.maybe_alias :bar, :foo
          expect(result).to be(Foo)
          expect(Foo.new.bar).to eq('foo')
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09013398294762484, 'fraction_numerical': 0.0, 'mean_word_length': 2.223529411764706, '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': '4501118', 'n_tokens_mistral': 268, 'n_tokens_neox': 248, 'n_words': 80}