<commit_before># Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require 'test_helper'

module Seahorse
  describe Client do

    def new_plugin
      @plugin_n ||= 0
      @plugin_n += 1
      plugin_name = "Plugin#{@plugin_n}"
      plugin_class = Class.new
      plugin_class.class.send(:define_method, :inspect) do
        plugin_name
      end
      plugin_class
    end

    def client_class
      @client_class ||= Class.new(Seahorse::Client)
      @client_class
    end

    describe '.add_plugin' do

      it 'adds plugins to the client' do
        plugin = new_plugin
        client_class.add_plugin(plugin)
        assert_equal([plugin], client_class.plugins)
      end

      it 'does not add plugins to the base class' do
        plugin = new_plugin
        subclass = Class.new(client_class)
        subclass.add_plugin(plugin)
        client_class.plugins.must_equal([])
        subclass.plugins.must_equal([plugin])
      end

    end

    describe '.remove_plugin' do

      it 'removes a plugin from the client class' do
        plugin1, plugin2, plugin3 = (1..3).map { new_plugin }
        client_class.add_plugin(plugin1)
        client_class.add_plugin(plugin2)
        client_class.add_plugin(plugin3)
        client_class.remove_plugin(plugin2)
        client_class.plugins.must_equal([plugin1, plugin3])
      end

      it 'does not remove plugins from parent class' do
        plugin1, plugin2 = [new_plugin, new_plugin]

        client_class.add_plugin(plugin1)
        client_class.add_plugin(plugin2)

        subclass = Class.new(client_class)
        subclass.remove_plugin(plugin2)

        client_class.plugins.must_equal([plugin1, plugin2])
        subclass.plugins.must_equal([plugin1])
      end
<commit_msg>Added return type tests for Client.add_plugin and .remove_plugin.<commit_after># Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require 'test_helper'

module Seahorse
  describe Client do

    def new_plugin
      @plugin_n ||= 0
      @plugin_n += 1
      plugin_name = "Plugin#{@plugin_n}"
      plugin_class = Class.new
      plugin_class.class.send(:define_method, :inspect) do
        plugin_name
      end
      plugin_class
    end

    def client_class
      @client_class ||= Class.new(Seahorse::Client)
      @client_class
    end

    describe '.add_plugin' do

      it 'adds plugins to the client' do
        plugin = new_plugin
        client_class.add_plugin(plugin)
        assert_equal([plugin], client_class.plugins)
      end

      it 'does not add plugins to the base class' do
        plugin = new_plugin
        subclass = Class.new(client_class)
        subclass.add_plugin(plugin)
        client_class.plugins.must_equal([])
        subclass.plugins.must_equal([plugin])
      end

      it 'returns nil' do
        client_class.add_plugin(new_plugin).must_equal(nil)
      end

    end

    describe '.remove_plugin' do

      it 'removes a plugin from the client class' do
        plugin1, plugin2, plugin3 = (1..3).map { new_plugin }
        client_class.add_plugin(plugin1)
        client_class.add_plugin(plugin2)
        client_class.add_plugin(plugin3)
        client_class.remove_plugin(plugin2)
        client_class.plugins.must_equal([plugin1, plugin3])
      end

      it 'does not remove plugins from parent class' do
        plugin1, plugin2 = [new_plugin, new_plugin]

        client_class.add_plugin(plugin1)
        client_class.add_plugin(plugin2)

        subclass = Class.new(client_class)
        subclass.remove_plugin(plugin2)

        client_class.plugins.must_equal([plugin1, plugin2])
        subclass.plugins.must_equal([plugin1])
      end

      it 'returns nil' do
        plugin = new_plugin
        client_class.add_plugin(plugin)
        client_class.remove_plugin(plugin).must_equal(nil)
      end

{'fraction_non_alphanumeric': 0.08111455108359134, 'fraction_numerical': 0.013622291021671827, 'mean_word_length': 2.7978056426332287, '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': '7541179', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1397, 'n_words': 410}